-
Notifications
You must be signed in to change notification settings - Fork 203
Description
I found that jsonld does not parse URIs with spaces. For example, this will return an empty result
import jsonld from "jsonld"
await jsonld.promises.toRDF({
"@id": "http://example.com/foo bar",
"@type": "http://example.com/Resource"
})
I worked fine until v2. I tracked it to this place in code. The isAbsolute
function is too strict and will reject identifiers which are not fully escaped.
Lines 108 to 111 in 20e2286
// skip relative IRI subjects (not valid RDF) | |
if(!_isAbsoluteIri(id)) { | |
continue; | |
} |
I find this was explicitly changed in #354 to "Do minimal checking to see if IRIs are valid by making sure they contain no whitespace." Which means that the function no longer only checks whether a URI is absolute or not...
This is problematic because since JavaScript does not have a full-blown URI representation, it is common to come across unescaped URIs, and they have to be taken at face value.
Otherwise, if jsonld wishes to normalise the URIs, the maybe encodeURI
would have to be called to ensure 100% correct URIs in the parsed output?