syntaxai/tdd.md · main · src / b32_git_url_redirect.ts
// b32 — Layer 1 pure helper: rewrite the legacy
// /GIT/syntaxai/tdd.md/<suffix> URL shape to /GIT/tdd.md/<suffix>.
// Pure: takes a pathname string, returns the new pathname or null
// when the input doesn't match the legacy shape. Called by the
// fallback handler to emit a 301 before the browse handler runs.
const OLD_GIT_URL_PATTERN = /^\/GIT\/syntaxai\/tdd\.md\/(.+)$/;
export const rewriteOldGitUrl = (pathname: string): string | null => {
const m = OLD_GIT_URL_PATTERN.exec(pathname);
if (m === null) return null;
return `/GIT/tdd.md/${m[1]}`;
};