Skip to content

fix(format): use RFC1123 hostname validator for legacy drafts#109

Open
Vaibhav701161 wants to merge 2 commits intohyperjump-io:mainfrom
Vaibhav701161:fix-legacy-hostname-validator
Open

fix(format): use RFC1123 hostname validator for legacy drafts#109
Vaibhav701161 wants to merge 2 commits intohyperjump-io:mainfrom
Vaibhav701161:fix-legacy-hostname-validator

Conversation

@Vaibhav701161
Copy link

Description

This PR fixes the validator used for the hostname format in legacy JSON Schema drafts.

Currently, the draft-04 hostname format handler calls isAsciiIdn from @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 isHostname validator in the formats package.

Change

The hostname format handler has been updated to use isHostname instead of isAsciiIdn.

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:

ab--cd.example

Before this change:

  • draft-04 → rejected
  • draft-06 → rejected

After this change:

  • draft-04 → accepted
  • draft-06 → accepted

Tests

A regression test was added to verify that hostnames containing consecutive hyphens (valid under RFC1123) are accepted for both:

  • draft-04
  • draft-06

The 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

  • Legacy hostname validation now matches the expected RFC1123 behavior.
  • The regression is covered by tests.
  • The full test suite passes with no regressions.

Closes #108.

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
@Vaibhav701161
Copy link
Author

@jdesrosiers please review the pull request.

@jdesrosiers
Copy link
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.

Copy link
Collaborator

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

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

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>
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.

draft-04 / draft-06 hostname format wired to IDNA validator instead of classic hostname validator

2 participants