diff --git a/src/features/settings/composables/__tests__/useSettingsPage.test.js b/src/features/settings/composables/__tests__/useSettingsPage.test.js index 6723aa3..b300c0c 100644 --- a/src/features/settings/composables/__tests__/useSettingsPage.test.js +++ b/src/features/settings/composables/__tests__/useSettingsPage.test.js @@ -47,7 +47,15 @@ describe('useSettingsPage', () => { { path: 'a..b..', expected: ['a', 'b'] }, { path: '.a..b..', expected: ['a', 'b'] }, { path: '..a..b.', expected: ['a', 'b'] }, - { path: '..a.....b.c..d....', expected: ['a', 'b', 'c', 'd'] } + { path: '..a.....b.c..d....', expected: ['a', 'b', 'c', 'd'] }, + { path: 'a.b.c/', expected: ['a', 'b', 'c'] }, + { path: 'a.#b.c', expected: ['a', 'b', 'c'] }, + { path: 'a.#b.c/', expected: ['a', 'b', 'c'] }, + { path: 'a1.#b.c/', expected: ['a1', 'b', 'c'] }, + { path: 'a-1.#b.c/', expected: ['a-1', 'b', 'c'] }, + { path: 'a-1.b@.c', expected: ['a-1', 'b', 'c'] }, + { path: '....@a/#...)!&§[b.#§c..d....', expected: ['a', 'b', 'c', 'd'] }, + { path: '....@a/#...)!&§[b.#§c..dä....', expected: ['a', 'b', 'c', 'd'] } ])('normalizes path correctly', async ({ path, expected }) => { expect(normalizePagePath(path)).toStrictEqual(expected); }); diff --git a/src/features/settings/composables/useSettingsPage.js b/src/features/settings/composables/useSettingsPage.js index f97ca11..3af36ab 100644 --- a/src/features/settings/composables/useSettingsPage.js +++ b/src/features/settings/composables/useSettingsPage.js @@ -20,7 +20,10 @@ export const normalizePagePath = function normalizePagePath (path) { return path .replace(/\.+/g, '.') .replace(/^\.+|\.+$/g, '') - .split('.'); + .split('.') + .map( + (segment) => segment.replace(/[^a-zA-Z0-9-]/g, '') + ); }; export const useSettingsPage = function useSettingsPage () {