import { CONSTRUCTION_NOTICE_PARAM, CONSTRUCTION_NOTICE_VALUE } from './types.js' /** `/pl/` → `/pl`, `` → `/` — paths compare without a trailing slash. */ export const normalizePath = (path: string): string => { const trimmed = path.replace(/\/+$/, '') return trimmed === '' ? '/' : trimmed } /** Is this pathname one of the allowed ones? Exact match, trailing slash ignored. */ export function isPathAllowed(pathname: string, allowedPaths: readonly string[]): boolean { const path = normalizePath(pathname) return allowedPaths.some((allowed) => normalizePath(allowed) === path) } /** Where a blocked address goes: the homepage with the notice parameter. */ export const constructionNoticeHref = (homePath: string): string => `${homePath}?${CONSTRUCTION_NOTICE_PARAM}=${CONSTRUCTION_NOTICE_VALUE}`