Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The valid URL “https://example--example.example.com/” is misjudged as invalid. #1315

Open
Narazaka opened this issue Oct 8, 2024 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@Narazaka
Copy link

Narazaka commented Oct 8, 2024

Bug Report

📝 Summary

Write a short summary of the bug in here.

  • Typia Version: 6.11.1, 7.0.0-dev.20241009-2

💻 Code occuring the bug

import { expect, test } from "vitest";
import {assert, type tags} from "typia";

type A = {
  url: string & tags.Format<"url">;
}

test("ex", async () => {
  expect(assert<A>({url: "https://example.com/"})).toBeTruthy();
});
test("--", async () => {
  expect(assert<A>({url: "https://example--example.example.com/"})).toBeTruthy();  // throws!
});
@samchon
Copy link
Owner

samchon commented Oct 8, 2024

Use uri instead.

@samchon samchon self-assigned this Oct 8, 2024
@samchon samchon added the question Further information is requested label Oct 8, 2024
@Narazaka
Copy link
Author

Narazaka commented Oct 8, 2024

But I would like to state that it is a URL, not a URI. The https://example--example.example.com/ is also valid as a URL.

@samchon
Copy link
Owner

samchon commented Oct 8, 2024

https://github.com/ajv-validator/ajv-formats/blob/master/src/formats.ts#L63

I'm following the ajv's validation logic.

Need to investigate the such example--example sub-domain is valid.

@Narazaka
Copy link
Author

Narazaka commented Oct 9, 2024

I think valid because the domains that has double or more hyphen actually exists

and RFC says only that leading and trailing hyphen is not allowed.

hostname       = *[ domainlabel "." ] toplabel
domainlabel    = alphadigit | alphadigit *[ alphadigit | "-" ] alphadigit
toplabel       = alpha | alpha *[ alphadigit | "-" ] alphadigit

@Narazaka
Copy link
Author

Narazaka commented Oct 9, 2024

To begin with, the xn--prefix of the internationalized domain is the typical double hyphen. (That is why some domain registrars that use internationalized domains go out of their way to state that they do not tolerate double hyphens in the third and fourth characters.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants