json-schema-ref-parser
json-schema-ref-parser copied to clipboard
Custom resolver casing change
Hi, thanks for the really great library. However, I think I have spotted a bug and can't seem to figure out where/why it's happening. Given an object like this:
{
"$ref": "custom://Path/Is/Case/Sensitive"
}
And a custom resolver like the following:
module.exports = {
order: 1,
canRead: /^custom:\/\//i,
read: function(file) {
console.log(file.url);
...
},
...
}
The url
value logged to the console would be: "custom://path/Is/Case/Sensitive"
, note the p
casing change. Is this something I'm doing or possibly a bug?
Thanks for reporting this. It does indeed appear to be a bug. I've reproduced it here: https://runkit.com/bigstickcarpet/json-schema-ref-parser-issue-49
Morning, any news on this ?
@setheal Please try and recreate and if you can a pull request would be very welcome.
I'm seeing a version of the same issue. If my $ref is template:personName.template
then the file URL I get is 'personname.template', i.e. the whole thing is lower cased. Any chance of it being fixed?
Looks like the fundamental issue is that the package assumes it is a URL (not just a URI) unless it is javascript: which in the static hostlessProtocol list found in url.js. I can see two ways to fix this:
- Allow people to specify a protocol is hostless in the options.
- Not assume it is a URL.