From 24b4e451160e6667dac43a71e29042cedea36bf6 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Mon, 27 Jul 2026 10:46:44 +0200 Subject: [PATCH] feat(settings): add page path normalization type check Added a type check to the normalizePagePath function. The function now returns an empty array if the path is not a string. --- .../settings/composables/__tests__/useSettingsPage.test.js | 7 ++++++- src/features/settings/composables/useSettingsPage.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/features/settings/composables/__tests__/useSettingsPage.test.js b/src/features/settings/composables/__tests__/useSettingsPage.test.js index b9fb1e9..89fb3f3 100644 --- a/src/features/settings/composables/__tests__/useSettingsPage.test.js +++ b/src/features/settings/composables/__tests__/useSettingsPage.test.js @@ -57,7 +57,12 @@ describe('useSettingsPage', () => { { 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'] } + { path: 'a.@.b', expected: ['a', 'b'] }, + { path: 1, expected: [] }, + { path: false, expected: [] }, + { path: true, expected: [] }, + { path: null, expected: [] }, + { path: undefined, expected: [] } ])('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 d06dee2..4dbf8e1 100644 --- a/src/features/settings/composables/useSettingsPage.js +++ b/src/features/settings/composables/useSettingsPage.js @@ -17,6 +17,7 @@ limitations under the License. import { useRouter } from 'vue-router'; export const normalizePagePath = function normalizePagePath (path) { + if (typeof path !== 'string') return []; return path .replace(/^\.+|\.+$/g, '') .split('.')