refactor(settings): move setttings path normalization utility to a separate file

Moved the normalizePagePath utility from the settings page composable to
a separate utility file and restructured tests accordingly.
This commit is contained in:
2026-07-28 20:10:23 +02:00
parent d6e7104f82
commit bd30579923
4 changed files with 106 additions and 67 deletions
@@ -14,19 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { getSettingsPagePathSegments } from '../utils/settingsPage';
import { useRouter } from 'vue-router';
export const normalizePagePath = function normalizePagePath (path) {
if (typeof path !== 'string') return [];
return path
.replace(/^\.+|\.+$/g, '')
.split('.')
.map(
(segment) => segment.replace(/[^a-zA-Z0-9-]/g, '')
)
.filter(Boolean);
};
export const useSettingsPage = function useSettingsPage () {
const router = useRouter();
@@ -34,7 +24,7 @@ export const useSettingsPage = function useSettingsPage () {
return router.push({
name: 'settings',
params: {
rest: normalizePagePath(pagePath)
rest: getSettingsPagePathSegments(pagePath)
}
});
};