Skip to content

feat: add origin validator for web origin URLs#1565

Merged
nodivbyzero merged 2 commits into
go-playground:masterfrom
ahmedkamalio:tag/origin
Apr 27, 2026
Merged

feat: add origin validator for web origin URLs#1565
nodivbyzero merged 2 commits into
go-playground:masterfrom
ahmedkamalio:tag/origin

Conversation

@ahmedkamalio
Copy link
Copy Markdown
Contributor

Fixes Or Enhances

Added origin tag for web origin URLs.

Make sure that you've checked the boxes below before you submit PR:

  • Tests exist or have been written that cover this particular change.

@go-playground/validator-maintainers

Signed-off-by: Ahmed Kamal <ahmed@ahmedkamal.io>
@ahmedkamalio ahmedkamalio requested a review from a team as a code owner April 20, 2026 00:58
Comment thread baked_in.go Outdated
Comment thread baked_in.go Outdated
Comment thread validator_test.go
- Replace permissive RFC1123 hostname regex with one that rejects leading/
  trailing hyphens per label, empty labels, and trailing dots
- Reorder origin host check to try net.ParseIP before regex (cheaper path
  for IP literals) and simplify single-case switch to an if
- Add tests covering invalid hostname/origin edge cases

Signed-off-by: Ahmed Kamal <ahmed@ahmedkamal.io>
@ahmedkamalio
Copy link
Copy Markdown
Contributor Author

@nodivbyzero nodivbyzero merged commit 6bcb7bc into go-playground:master Apr 27, 2026
7 checks passed
@ahmedkamalio ahmedkamalio deleted the tag/origin branch April 27, 2026 23:53
zemzale pushed a commit that referenced this pull request Apr 29, 2026
## Fixes Or Enhances

Similar to the recent fix #1565 6bcb7bc RFC 952 is now fixed to reject
hostname labels with trailing hyphen

**Make sure that you've checked the boxes below before you submit PR:**
- [x] Tests exist or have been written that cover this particular
change.

@go-playground/validator-maintainers

Signed-off-by: Ahmed Kamal <ahmed@ahmedkamal.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants