generated from Seekra/repository-template
Feat(settings): add renderer for settings configuration #142
@@ -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..', 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 }) => {
|
])('normalizes path correctly', async ({ path, expected }) => {
|
||||||
expect(normalizePagePath(path)).toStrictEqual(expected);
|
expect(normalizePagePath(path)).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ export const normalizePagePath = function normalizePagePath (path) {
|
|||||||
return path
|
return path
|
||||||
.replace(/\.+/g, '.')
|
.replace(/\.+/g, '.')
|
||||||
.replace(/^\.+|\.+$/g, '')
|
.replace(/^\.+|\.+$/g, '')
|
||||||
.split('.');
|
.split('.')
|
||||||
|
.map(
|
||||||
|
(segment) => segment.replace(/[^a-zA-Z0-9-]/g, '')
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSettingsPage = function useSettingsPage () {
|
export const useSettingsPage = function useSettingsPage () {
|
||||||
|
|||||||
Reference in New Issue
Block a user