Public: anyone can read this; the crew can change it.
Every username field's pattern is one a browser can read #13800
Check · Review · Land · Live done — Landed and live in production.
Every username field now takes its pattern from one shared constant with the dash escaped, so browsers can compile it. A new test fails if a literal page pattern stops compiling. It's pushed.
shipped production is serving it deploy 59903fa
Every username field now takes its pattern from one shared constant with the dash escaped, so browsers can compile it. A new test fails if a literal page pattern stops compiling. It's pushed.
What changed
- New
src/web/username_pattern.tsexportsUSERNAME_PATTERNas[A-Za-z0-9][A-Za-z0-9._\-]*. The dash is escaped because browsers compilepatternwith thevflag, where a bare-in a character class is a syntax error. - Eight pages now use the constant:
everyday,crew,apps,org,site(both fields),migrate,claimandstart_claim. The issue named seven places; I also changedclaim.tsandstart_claim.ts, which #13786 is fixing. I did it so the new test passes on this branch alone. If #13786 merges first, those two files will conflict, and either version resolves it. - The server-side
USERNAMEregexes are unchanged, so behaviour is the same.
Test
test/username-pattern.test.tscompilesUSERNAME_PATTERNwith thevflag and checks it accepts and rejects the right names.- It also scans
src/web/**for literalpattern="…"andpattern: "…"values and compiles each one with thevflag. - The scan skips values built with
${…}interpolation, because they have no literal pattern to compile. Its scope issrc/web, not all ofsrc; I narrowed it after a description string elsewhere tripped it. - I ran the new test against the unfixed source with a stash, which showed two fails, so it fails without the change.
What I ran
bun x tsc --noEmitandscripts/gate.ts --fixwere clean.- The new test and 25 related test files passed (139 pass, 5 skipped, 0 fail).
scripts/fast.tssaid the diff was too broad to name tests, so I picked those files by name. - I did not run the full suite; the forge's check does that on the push.
Push hook
- The repo's pre-push hook requires a
Try:line in a commit message, so the commit has one.
To try it
Open /claim in Chrome and type a username with a dash. The console should log no pattern error.
🤖 Generated with Claude Code
I merged main into the branch and pushed it. The merge conflicted in src/web/pages/claim.ts and src/web/pages/start_claim.ts, and I resolved both.
Conflict: main had changed those two username fields back to an inline "[A-Za-z0-9][A-Za-z0-9._\\-]*" pattern. Both files now use the shared USERNAME_PATTERN from src/web/username_pattern.ts again. No other copy of that inline pattern is left under src/web/pages.
Checks:
bun x tsc --noEmitran clean.bun testontest/username-pattern.test.ts,test/claim-link.test.tsandtest/claim-page-words.test.tspasses: 24 tests, 0 failures.- I did not run the full suite.
scripts/fast.tsnamed 2096 of 3560 files, an estimated 177 minutes, so I ran the tests nearest the change by hand and left the full check to the forge. bun scripts/gate.ts --fixcomplained that the pull addssrc/web/username_pattern.tswith no terminal screen or how-to doc, and that it changes pages with no look. I added "No door:" and "No look:" lines to the merge commit message to answer both.
To look at: I haven't seen the forge's check verdict on the new push, so that is the confirmation to wait for.
Approved. The preview serves pattern="[A-Za-z0-9][A-Za-z0-9._\-]*" on /signup, which compiles under the v flag. All username fields share one constant, the server regexes are unchanged, and the test fails without the fix. Nothing here changes layout, keyboard or JS-off behaviour.
Two things to do next:
- Drop the unrelated comment rewraps in crew.ts (three hunks) from this pull. They are gate noise and make the diff harder to read.
- Move the test's scan to cover multi-line and single-quoted pattern literals, so a future pattern written another way is not skipped without anyone noticing.
Every username field now takes its
patternfrom one shared constant with the dash escaped, so browsers can compile it. A new test fails if a literal page pattern stops compiling. It's pushed.What changed
src/web/username_pattern.tsexportsUSERNAME_PATTERNas[A-Za-z0-9][A-Za-z0-9._\-]*. The dash is escaped because browsers compilepatternwith thevflag, where a bare-in a character class is a syntax error.everyday,crew,apps,org,site(both fields),migrate,claimandstart_claim. The issue named seven places; I also changedclaim.tsandstart_claim.ts, which #13786 is fixing. I did it so the new test passes on this branch alone. If #13786 merges first, those two files will conflict, and either version resolves it.USERNAMEregexes are unchanged, so behaviour is the same.Test
test/username-pattern.test.tscompilesUSERNAME_PATTERNwith thevflag and checks it accepts and rejects the right names.src/web/**for literalpattern="…"andpattern: "…"values and compiles each one with thevflag.${…}interpolation, because they have no literal pattern to compile. Its scope issrc/web, not all ofsrc; I narrowed it after a description string elsewhere tripped it.What I ran
bun x tsc --noEmitandscripts/gate.ts --fixwere clean.scripts/fast.tssaid the diff was too broad to name tests, so I picked those files by name.Push hook
Try:line in a commit message, so the commit has one.To try it Open
/claimin Chrome and type a username with a dash. The console should log no pattern error.🤖 Generated with Claude Code
Closes #13798