Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions apps/web/src/app/wait-list/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ export const WAITLIST_EMAIL_TYPES = [
] as const;

export const waitlistSubmissionSchema = z.object({
domain: z
.string({ required_error: "Domain is required" })
.trim()
.min(1, "Domain is required")
.max(255, "Domain must be 255 characters or fewer"),
domain: z
.string({ required_error: "Domain is required" })
.trim()
.min(1, "Domain is required")
.max(255, "Domain must be 255 characters or fewer")
.regex(
/^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
"Please enter a valid domain (e.g. example.com)"
Comment on lines +15 to +16
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Regex still accepts invalid hyphenated labels

Line 15 currently allows invalid domains like -foo.com and foo-.com because each label is [a-zA-Z0-9-]+. Tighten each label so it cannot begin/end with -.

Proposed fix
-    /^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
+    /^(?!:\/\/)(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/^(?!:\/\/)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$/,
"Please enter a valid domain (e.g. example.com)"
/^(?!:\/\/)(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,
"Please enter a valid domain (e.g. example.com)"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/web/src/app/wait-list/schema.ts` around lines 15 - 16, The current
domain regex allows labels to start or end with hyphens; update the label
subpattern so each label must start and end with an alphanumeric character.
Replace the label token ([a-zA-Z0-9-]+) in the existing regex with a pattern
like [a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])? so the full regex becomes
/^(?!:\/\/)([a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/ (keep the
existing negative lookahead and TLD check as-is).

),
emailTypes: z
.array(z.enum(WAITLIST_EMAIL_TYPES))
.min(1, "Select at least one email type"),
Expand Down