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

is_iri should allow UTF-8 characters #25

Open
gu-stav opened this issue Mar 21, 2019 · 1 comment
Open

is_iri should allow UTF-8 characters #25

gu-stav opened this issue Mar 21, 2019 · 1 comment

Comments

@gu-stav
Copy link

gu-stav commented Mar 21, 2019

Currently is_iri fails on any characters, which don't match this regex:

if (/[^a-z0-9\:\/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~\%]/i.test(value)) return;

Example:

t.ok(is_uri('http://localhost/ä'), 'http://localhost/ä');

As far as I understand the main difference between URI and IRI is:

IRIs extend URIs by using the Universal Character Set, where URIs were limited to ASCII, with far fewer characters.

https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier

Therefore is_iri should allow all UTF-8 characters and these exports aren't correct:

module.exports.is_uri = is_iri;
module.exports.isUri = is_iri;

Instead there should be two exports: is_iri and is_uri.

I saw there wasn't any commit to this repo since 2015, but since this affects a Gatsby issue I was wondering, what you plans with the module are? Do you think about handing it over, @ogt?

The module is used heavily according to npms download numbers, so it might be in the interest of the community to give it some 💌 .

@adrienv1520
Copy link

Hi @gustavpursche,

I was facing the same issues with valid-url but also validator so I decided to build a module as reliable as possible strictly based on RFC-3986: https://github.com/adrienv1520/node-uri

The main features of this project are:

  • parse any URI (URNs, URLs, URIs with IDNs support, etc.);
  • get the safe Punycode ASCII or Unicode serialization of a domain;
  • check an URI, HTTP/HTTPS/Sitemap URL, IP, domain is valid with clear checking errors;
  • encode/decode an URI, HTTP/HTTPS/Sitemap URL.

I hope it could help you.

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

No branches or pull requests

2 participants