Skip to content

Commit 38d47d5

Browse files
authored
fix(docs): case-insensitive error-code URLs (#295)
1 parent 26cf0c5 commit 38d47d5

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* Error reference pages live at `/errors/DFxxxx` (uppercase, derived from the
3+
* content filenames). Accept any-case deep links like `/errors/df8111` and
4+
* redirect them to the canonical uppercase URL so a single URL is indexed.
5+
*/
6+
export default defineEventHandler((event) => {
7+
const match = /^\/errors\/(df\d{4})(?=\/|$|\?)/i.exec(event.path)
8+
if (!match)
9+
return
10+
const canonical = match[1].toUpperCase()
11+
if (match[1] === canonical)
12+
return // already canonical, let it through
13+
return sendRedirect(event, event.path.replace(match[1], canonical), 308)
14+
})

0 commit comments

Comments
 (0)