-
Notifications
You must be signed in to change notification settings - Fork 202
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
Don't expand non-string native values to node objects. #209
Conversation
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.
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. | |||
|
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.
We'll want to make this follow our convention. @davidlehn -- any tips/links to point out?
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.
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) { |
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.
Should use ! .includes
instead of indexOf
check.
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.
With two items is it better to just expand out the two 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.
Perhaps, but it makes it easier to alter in the future; I'll update to use !.includes
.
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.
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 think all indexOf() ===/!== -1
uses can be switched over to includes()
.
This change adds and fixes Expand test #0088, see https://json-ld.org/test-suite/tests/expand-manifest.jsonld#t0088. More details here: json-ld/json-ld.org#558 and here: digitalbazaar/jsonld.js#209
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.