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

uri() fails RFC3986 4.2 relative reference URIs #815

Closed
garthk opened this issue Feb 4, 2016 · 3 comments
Closed

uri() fails RFC3986 4.2 relative reference URIs #815

garthk opened this issue Feb 4, 2016 · 3 comments
Assignees
Labels
bug Bug or defect feature New functionality or improvement
Milestone

Comments

@garthk
Copy link

garthk commented Feb 4, 2016

> require('joi').string().uri().validate('/foo')
{ error: 
   { [ValidationError: "value" must be a valid uri]
…

A relative relative reference takes advantage of the hierarchical syntax(Section 1.2.3) to express a URI reference relative to the name space of another hierarchical URI
– RFC 3986 Section 4.2

If you insist on a URL being locatable, you should a) add a new method url to so insist, and b) consider what you're going to do about this case:

> require('joi').string().uri().validate('http:/')
{ error: null, value: 'http:/' }

Scenario: I'd like to issue relative paths to other documents from an API while keeping the option open to make them absolute. It feels wrong to document them as plain strings. I'd like the result, run through joi-to-json-schema, to wear the format uri.

@Marsup Marsup added bug Bug or defect request labels Feb 9, 2016
@Marsup Marsup self-assigned this Feb 9, 2016
@Marsup
Copy link
Collaborator

Marsup commented Feb 9, 2016

OK most of the code is done. Do you have a need to enforce relative uris only ?

@Marsup Marsup added this to the 7.3.0 milestone Feb 9, 2016
@Marsup Marsup closed this as completed in 93d22bf Feb 11, 2016
@garthk
Copy link
Author

garthk commented Feb 20, 2016

No, no such need. Thanks.

@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
bug Bug or defect feature New functionality or improvement
Projects
None yet
Development

No branches or pull requests

3 participants