From 6b347bb845324acfc09bc855d302c6306cec0206 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Mon, 27 Jul 2026 10:44:40 +0200 Subject: [PATCH] feat(settings): omit empty settings page segments The composable useSettingsPage now omits empty segments in the path. --- .../settings/composables/__tests__/useSettingsPage.test.js | 4 +++- src/features/settings/composables/useSettingsPage.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/features/settings/composables/__tests__/useSettingsPage.test.js b/src/features/settings/composables/__tests__/useSettingsPage.test.js index b300c0c..b9fb1e9 100644 --- a/src/features/settings/composables/__tests__/useSettingsPage.test.js +++ b/src/features/settings/composables/__tests__/useSettingsPage.test.js @@ -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); }); diff --git a/src/features/settings/composables/useSettingsPage.js b/src/features/settings/composables/useSettingsPage.js index 3af36ab..d06dee2 100644 --- a/src/features/settings/composables/useSettingsPage.js +++ b/src/features/settings/composables/useSettingsPage.js @@ -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 () {