Skip to content

Commit d55fea8

Browse files
authored
Merge pull request #56 from DEVxNetwork/sam/fix-55
Fix invalid regex with hyphens in ranges
2 parents 249df16 + 442c993 commit d55fea8

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

app/setup/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default function Setup() {
117117
}
118118

119119
// Validate handle format: lowercase alphanumeric with underscores/hyphens, 3-30 chars
120-
const handleRegex = /^[a-z0-9_-]+$/
120+
const handleRegex = /^(?:[a-z0-9_]|-)+$/
121121
if (!handleRegex.test(handle) || handle.length < 3 || handle.length > 30) {
122122
setHandleAvailable(false)
123123
return
@@ -305,7 +305,7 @@ export default function Setup() {
305305
onChange={(e) => setHandle(e.target.value.toLowerCase())}
306306
placeholder="your-handle"
307307
required
308-
pattern="[a-z0-9_-]{3,30}"
308+
pattern="(?:[a-z0-9_]|-){3,30}"
309309
minLength={3}
310310
maxLength={30}
311311
/>

scripts/update-events.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ async function scrapeEventPage(
563563

564564
if (normalizedText) {
565565
domLocationText = normalizedText
566-
const cityStateRegex = /([A-Za-z][A-Za-z\s.'-]+?),\s*([A-Z]{2})(?:\s|,|$)/
566+
const cityStateRegex = /([A-Za-z](?:[A-Za-z\s.']|-)+?),\s*([A-Z]{2})(?:\s|,|$)/
567567
const cityStateMatch = normalizedText.match(cityStateRegex)
568568

569569
if (cityStateMatch) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Update handle format constraint to use clearer alternation pattern
2+
-- This avoids ambiguity with hyphens in character classes
3+
ALTER TABLE profiles
4+
DROP CONSTRAINT IF EXISTS handle_format_check;
5+
6+
ALTER TABLE profiles
7+
ADD CONSTRAINT handle_format_check CHECK (
8+
handle IS NULL OR (
9+
handle ~ '^(?:[a-z0-9_]|-)+$' AND
10+
LENGTH(handle) >= 3 AND
11+
LENGTH(handle) <= 30
12+
)
13+
);
14+

0 commit comments

Comments
 (0)