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

Supporting Internationalized Resource Identifier (RFC 3987) #1164

Closed
Xrampino opened this issue Apr 18, 2017 · 7 comments
Closed

Supporting Internationalized Resource Identifier (RFC 3987) #1164

Xrampino opened this issue Apr 18, 2017 · 7 comments
Assignees
Labels
feature New functionality or improvement

Comments

@Xrampino
Copy link

URL validation right now fails with the widely-supported IRI (RFC-3987), for example https://www.example.com/michaël.

This library seems to support it, could it be possible to switch to this one for URL validation internally ? https://github.com/garycourt/uri-js

@WesTyler
Copy link
Contributor

There's little chance that a new dependency will be added, since Joi is itself a dependency of hapi and those downstream deps are verrrry closely guarded.

That being said, that's not the only option for adding internationalization validation. If @Marsup gives the broad goal of supporting international characters in uri validation, I'll put this on my radar, right behind isemail; anyone else who wants to take a stab though has my full support! I am happy to help where I can.

@WesTyler
Copy link
Contributor

Hm, actually, I think the decision whether or not to include IRIs by default in the validation comes down to the intended function of Joi.string().uri().

From RFC 3987 section 1.2.a -

in the HTTP protocol [RFC2616], the Request URI is defined
as a URI, which means that direct use of IRIs is not allowed in
HTTP requests

So, if Joi.string().uri() is being used to validate the endpoint for an HTTP request, IRIs should fail. But that's not the only use for URI validation.

@Xrampino
Copy link
Author

Xrampino commented Apr 20, 2017

I think they mean it should be normalized to punycode internally. But for the facing user https://www.examplé.com is still a valid domain, right?

Maybe we should talk about addingJoi.string().webAddress() to avoid confusion?

@WesTyler
Copy link
Contributor

Admittedly I didn't have the chance to finish reading the RFC yet... :P

@DavidTPate
Copy link
Contributor

@Xrampino This is where things become interesting because there's a number of different RFCs which apply to this. From what I've dug through you are correct that there are some specifications out there which do indeed support non-ASCII characters within the user's browser. These are then converted from Unicode to ASCII.

I agree with you that I don't think we should be modifying Joi.string().uri(). There are some different parsing mechanisms that are mentioned within the WhatWG work group for URL from what was specified in RFC-3986. These again are different from RFC-3987 which was also mentioned and handles IRIs.

@Marsup Marsup self-assigned this Aug 14, 2018
@Marsup Marsup added the request label Aug 14, 2018
@Marsup
Copy link
Collaborator

Marsup commented Aug 14, 2018

There hasn't been any demand for that in the past few years, nobody volunteered to implement it, and I don't see any joi extension doing it. Shall I close ?

@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

5 participants