mafintosh/is-my-json-valid

support relative URIs per RFC1808 and RFC3986

coderextreme opened this issue · 8 comments

Need to support leading . and .. for "format" : "uri"

or at least leading ..

@coderextreme Could you elaborate on your request? I don't see any use of relative paths in your examples. Is this in regards to remote $refs? They're not supported by this module

No, it's not remote refs, It's properties (@url, @*Url) marked as "format": "uri" in my schema. I need to validate URI's in my documents, and documents with a URI of .. don't pass. I have overridden the URI format for now. Thanks!

The following works fine for me:

var validate = require('is-my-json-valid')({type: 'string', format: 'uri'})

validate('http://hello.world/../hello.txt') // true

@emilbayes @coderextreme format "uri" was poorly specified in draft-04. Technially, it indicates a full URI (with scheme). The "uri-reference" format added in draft-06 is what would handle "../hello.txt" as a URI reference to be resolved against the current base per RFC 3986

I'm going to close this. Well maybe not through the iPad app :(

We could add uri-reference in addition to the uri format:

exports['uri'] = /^[a-zA-Z][a-zA-Z0-9+\-.]*:[^\s]*$/