Skip to content
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

Merged
merged 5 commits into from
Feb 2, 2017

Conversation

timbl
Copy link
Member

@timbl timbl commented Feb 2, 2017

Strip spaces and any params from media type when generating an RDF type
Add content type default of turtle to rdf.parse

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) {
Copy link
Contributor

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?

@dmitrizagidulin
Copy link
Contributor

👍 , looks fine to me.

var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.'
console.log(message)
// throw new Error(message)
iri = encodeURI(iri)
Copy link
Contributor

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?

Copy link
Contributor

@dan-f dan-f left a 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 || {}
Copy link
Contributor

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

Copy link
Contributor

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.

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.'
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

}
if (iri.indexOf(' ') >= 0) {
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.'
console.log(message)
Copy link
Contributor

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.

@dmitrizagidulin
Copy link
Contributor

Added tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants