-
Notifications
You must be signed in to change notification settings - Fork 146
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
Strip spaces and any params from media type when generating an RDF type #167
Conversation
src/named-node.js
Outdated
console.log('Warning: NamedNode IRI "' + iri + '" must be absolute. Relative URIs will fail in future versions') | ||
console.log('Error: NamedNode IRI "' + iri + '" must be absolute. Relative URIs will fail in future versions') | ||
} | ||
if (iri.indexOf(' ') >= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe iri.includes(' ')
might be slightly clearer/more idiomatic?
👍 , looks fine to me. |
src/named-node.js
Outdated
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.' | ||
console.log(message) | ||
// throw new Error(message) | ||
iri = encodeURI(iri) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Er, wait a second, should this be the right behavior? To automatically encodeURI
the full node uri?
What's the use case you're encountering, when spaces are being passed in to a named node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs some tests! :)
src/fetcher.js
Outdated
@@ -586,6 +586,7 @@ var Fetcher = function Fetcher (store, timeout, async) { | |||
// Writes back to the web what we have in the store for this uri | |||
this.putBack = function (uri, options) { | |||
uri = uri.uri || uri // Accept object or string | |||
options = options || {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can alternatively use ES2015 default argument syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, changed it to use default argument syntax.
src/named-node.js
Outdated
console.log('Error: NamedNode IRI "' + iri + '" must be absolute. Relative URIs will fail in future versions') | ||
} | ||
if (iri.indexOf(' ') >= 0) { | ||
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be worth it to use a URL validation library rather these ad-hoc checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Shall we open an issue for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, might as well do it now? I don't particularly mind either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened issue #168 as a reminder.
src/named-node.js
Outdated
} | ||
if (iri.indexOf(' ') >= 0) { | ||
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.' | ||
console.log(message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why console.log()
the message? It seems like constructing a named node from an invalid URI should simply be an error.
Added tests. |
Strip spaces and any params from media type when generating an RDF type
Add content type default of turtle to rdf.parse