Improved import security, added browser tests
Some checks failed
Tests et déploiement / deploy (push) Has been cancelled
Tests et déploiement / validate (push) Has been cancelled

This commit is contained in:
2026-10-08 21:34:58 +02:00
parent 5cf19bb8ac
commit b0aa5acf4b
28 changed files with 793 additions and 99 deletions

View File

@@ -9,18 +9,23 @@
const ROUTES = ['resume', 'today', 'settings', 'stats', 'details', 'automations', 'non-working'];
function fromHash() {
const h = location.hash.replace(/^#\/?/, '');
return ROUTES.includes(h) ? h : null;
const [path, query = ''] = location.hash.replace(/^#\/?/, '').split('?');
const date = new URLSearchParams(query).get('date');
return { route: ROUTES.includes(path) ? path : null,
selectedDate: date && /^\d{4}-\d{2}-\d{2}$/.test(date) ? date : '' };
}
export const router = $state({ route: fromHash(), selectedDate: '' });
export const router = $state(fromHash());
window.addEventListener('hashchange', () => {
router.route = fromHash();
const next = fromHash();
router.route = next.route;
if (next.selectedDate) router.selectedDate = next.selectedDate;
});
export function go(route) {
location.hash = route ? `#/${route}` : '';
const date = ['resume', 'details'].includes(route) && router.selectedDate ? `?date=${router.selectedDate}` : '';
location.hash = route ? `#/${route}${date}` : '';
}
export function back() {