Skip to content

Commit

Permalink
Revert "formatApiPath / formatAssetPath - Implement smart functionali…
Browse files Browse the repository at this point in the history
…ty to detect double subpath" (#3001)

Reverts #2777
  • Loading branch information
sjaanus authored and Gastón Fournier committed Jan 26, 2023
1 parent cdc1f26 commit 8efd0f8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
2 changes: 0 additions & 2 deletions frontend/src/utils/formatPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand All @@ -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');
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/utils/formatPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8efd0f8

Please sign in to comment.