mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Revert "formatApiPath / formatAssetPath - Implement smart functionality to detect double subpath" (#3001)
Reverts Unleash/unleash#2777
This commit is contained in:
parent
04dad9e33e
commit
b80e84b438
@ -28,7 +28,6 @@ test('formatAssetPath', () => {
|
||||
expect(formatAssetPath('/a', '/x')).toEqual('/x/a');
|
||||
expect(formatAssetPath('/a/', '/x/')).toEqual('/x/a');
|
||||
expect(formatAssetPath('a/b/', 'x/y/')).toEqual('/x/y/a/b');
|
||||
expect(formatAssetPath('x/y/', 'x/y/')).toEqual('/x/y');
|
||||
expect(formatAssetPath('//a//b//', '//x//y//')).toEqual('/x/y/a/b');
|
||||
});
|
||||
|
||||
@ -43,7 +42,6 @@ test('formatApiPath', () => {
|
||||
expect(formatApiPath('/', '/')).toEqual('');
|
||||
expect(formatApiPath('a', 'x')).toEqual('/x/a');
|
||||
expect(formatApiPath('/a', '/x')).toEqual('/x/a');
|
||||
expect(formatApiPath('/a', '/x/a')).toEqual('/x/a');
|
||||
expect(formatApiPath('/a/', '/x/')).toEqual('/x/a');
|
||||
expect(formatApiPath('a/b/', 'x/y/')).toEqual('/x/y/a/b');
|
||||
expect(formatApiPath('//a//b//', '//x//y//')).toEqual('/x/y/a/b');
|
||||
|
@ -23,14 +23,7 @@ export const parseBasePath = (value = basePathMetaTagContent()): string => {
|
||||
|
||||
// Join paths with a leading separator and without a trailing separator.
|
||||
const joinPaths = (...paths: string[]): string => {
|
||||
const filteredPaths = paths.filter(path => {
|
||||
return !paths.some(
|
||||
currentPath => currentPath !== path && currentPath.includes(path)
|
||||
);
|
||||
});
|
||||
const uniquePaths = [...new Set(filteredPaths)];
|
||||
|
||||
return ['', ...uniquePaths]
|
||||
return ['', ...paths]
|
||||
.join('/')
|
||||
.replace(/\/+$/g, '') // Remove trailing separators.
|
||||
.replace(/\/+/g, '/'); // Collapse repeated separators.
|
||||
|
Loading…
Reference in New Issue
Block a user