Skip to content

Don't expand non-string native values to node objects. #209

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

Merged
merged 4 commits into from
Jan 9, 2018

Conversation

gkellogg
Copy link
Collaborator

@gkellogg gkellogg commented Jan 7, 2018

As called for in json-ld/json-ld.org#558. There is new text in 1.1 (not dependent on "@version": 1.1) to ensure that native types won't be coerced to IRIs. It's quite reasonable for 1.0 processors, as such coercion is nonsensical.

Copy link
Member

@dlongley dlongley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than some nits -- will approve once those are addressed.

@@ -5,6 +5,9 @@
feature added complexity and browser issues and the use case is likely
handled by semantic versioning and using a proper dependency.

## 0.5.x
- Do not use native types to create IRIs in value expansion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll want to make this follow our convention. @davidlehn -- any tips/links to point out?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added similar comment here: https://github.com/digitalbazaar/jsonld.js/pull/210/files#r160245707
I'll fix it for next 0.5.x release.

lib/expand.js Outdated
@@ -590,7 +590,7 @@ function _expandValue({activeCtx, activeProperty, value}) {

const rval = {};

if(type !== null) {
if(type && ['@id', '@vocab'].indexOf(type) === -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use ! .includes instead of indexOf check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With two items is it better to just expand out the two checks?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, but it makes it easier to alter in the future; I'll update to use !.includes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all indexOf() ===/!== -1 uses can be switched over to includes().

@davidlehn davidlehn merged commit 9a505ac into digitalbazaar:0.5.x Jan 9, 2018
@gkellogg gkellogg deleted the no-expand-native-as-object branch January 10, 2018 00:40
kazarena added a commit to piprate/json-gold that referenced this pull request Dec 26, 2018
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.

3 participants