feat(settings): omit empty settings page segments

The composable useSettingsPage now omits empty segments in the path.
This commit is contained in:
2026-07-27 19:05:04 +02:00
parent 966a984eb0
commit e14ce45849
2 changed files with 5 additions and 3 deletions
@@ -55,7 +55,9 @@ describe('useSettingsPage', () => {
{ 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'] }
{ path: '....@a/#...)!&§[b.#§c..dä....', expected: ['a', 'b', 'c', 'd'] },
{ path: '..,...~..@a/#.+..)!&§[b.#§c..dä..)..', expected: ['a', 'b', 'c', 'd'] },
{ path: 'a.@.b', expected: ['a', 'b'] }
])('normalizes path correctly', async ({ path, expected }) => {
expect(normalizePagePath(path)).toStrictEqual(expected);
});
@@ -18,12 +18,12 @@ import { useRouter } from 'vue-router';
export const normalizePagePath = function normalizePagePath (path) {
return path
.replace(/\.+/g, '.')
.replace(/^\.+|\.+$/g, '')
.split('.')
.map(
(segment) => segment.replace(/[^a-zA-Z0-9-]/g, '')
);
)
.filter(Boolean);
};
export const useSettingsPage = function useSettingsPage () {