1
0
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:
sjaanus 2023-01-26 16:34:42 +02:00 committed by GitHub
parent 04dad9e33e
commit b80e84b438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 10 deletions

View File

@ -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');

View File

@ -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.