Improve verification of DOM string IRI
object opened this issue · 2 comments
object commented
This one is marked in the source code as "TODO" item, however I would like to emphasize its importance. Right now if I serialize and object into a JSON string and send it to JsonLdProcessor.Expand, it will mistakenly interpret it as a URI and of course fail. This is due to very weak check if in the code:
(input.Type == JTokenType.String && ((string)input).Contains(":"))
If it's a URI string that is expected would it be sufficient to match a regex here?
lanthaler commented
Yeah, that’s true. In my implementation I check the first non-whitespace character. If it is a “[“ or “{“, you’ll now that it is a JSON array or object (those are the only two supported top-level structures); if not, it is a URL (or an error).