fix(format): use RFC1123 hostname validator for legacy drafts#109
Open
Vaibhav701161 wants to merge 2 commits intohyperjump-io:mainfrom
Open
fix(format): use RFC1123 hostname validator for legacy drafts#109Vaibhav701161 wants to merge 2 commits intohyperjump-io:mainfrom
Vaibhav701161 wants to merge 2 commits intohyperjump-io:mainfrom
Conversation
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Author
|
@jdesrosiers please review the pull request. |
Collaborator
|
Don't leave a comment asking for review. It's unnecessary and frankly it's annoying. I get notified of all activity in this repo. |
jdesrosiers
requested changes
Mar 13, 2026
Collaborator
jdesrosiers
left a comment
There was a problem hiding this comment.
Remove the test. This should be included in https://github.com/json-schema-org/JSON-Schema-Test-Suite/. Please go add it there instead.
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes the validator used for the
hostnameformat in legacy JSON Schema drafts.Currently, the
draft-04hostname format handler callsisAsciiIdnfrom@hyperjump/json-schema-formats. That validator applies IDNA / UTS-46 restrictions, which are stricter than the classic hostname rules expected by legacy JSON Schema drafts.However, drafts draft-04 and draft-06 expect hostname validation consistent with RFC1123, which is implemented by the
isHostnamevalidator in the formats package.Change
The hostname format handler has been updated to use
isHostnameinstead ofisAsciiIdn.This ensures that legacy drafts validate hostnames using RFC1123 rules rather than IDNA restrictions.
Example
The following hostname is valid under RFC1123 but rejected under IDNA rules:
Before this change:
draft-04→ rejecteddraft-06→ rejectedAfter this change:
draft-04→ accepteddraft-06→ acceptedTests
A regression test was added to verify that hostnames containing consecutive hyphens (valid under RFC1123) are accepted for both:
draft-04draft-06The regression test was placed in a dedicated spec file (
formats/hostname.spec.ts) to follow the repository’s convention of keeping custom tests separate from the JSON Schema Test Suite runners.Result
Closes #108.