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

isURL() #1253

Open
wimastop opened this issue Feb 24, 2020 · 4 comments
Open

isURL() #1253

wimastop opened this issue Feb 24, 2020 · 4 comments

Comments

@wimastop
Copy link

validator.isURL('http://_.test.com',{allow_underscores:true}); is false

@profnandaa
Copy link
Member

Not sure if _ alone should pass for a sub-domain...

@dok
Copy link

dok commented Mar 30, 2020

Yep, I'm seeing this as well. See here

Mind if I make a PR for this fix?

@profnandaa
Copy link
Member

@dok -- you test case is a different one, can you add allow_underscores?

@gibson042
Copy link
Contributor

There's nothing special about underscore, lone or otherwise. Domain names in common display format are composed of dot-separated labels, and each label may contain any octet in any order (including not just underscore, but also ASCII control characters like 0x00 and 0x7F and non-ASCII values like 0xA0). The subset of domain names that are "host names" limit label octets to ASCII letters, digits, and hyphens (LDH) via the "preferred name syntax", but it remains possible to resolve and use domain names outside of that subset. From RFC 8499 (emphasis mine):

Host name: This term and its equivalent, "hostname", have been widely used but are not defined in [RFC1034], [RFC1035], [RFC1123], or [RFC2181]. The DNS was originally deployed into the Host Tables environment as outlined in [RFC952], and it is likely that the term followed informally from the definition there. Over time, the definition seems to have shifted. "Host name" is often meant to be a domain name that follows the rules in Section 3.5 of [RFC1034], which is also called the "preferred name syntax". (In that syntax, every character in each label is a letter, a digit, or a hyphen). Note that any label in a domain name can contain any octet value; hostnames are generally considered to be domain names where every label follows the rules in the "preferred name syntax", with the amendment that labels can start with ASCII digits (this amendment comes from Section 2.1 of [RFC1123]).

People also sometimes use the term "hostname" to refer to just the first label of an FQDN, such as "printer" in "printer.admin.example.com". (Sometimes this is formalized in configuration in operating systems.) In addition, people sometimes use this term to describe any name that refers to a machine, and those might include labels that do not conform to the "preferred name syntax".

So if "foo_bar.example.com" is accepted with a given set of options, then "_.example.com" should be as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants