digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

When expanded IRI starts with @ returns null #401

Open g-yonchev opened 4 years ago

g-yonchev commented 4 years ago

Hello!

It seems that when I do

const compacted = {
  '@context': 'https://schema.org/',
  '@type': 'Organization',
   sameAs: [
    '@test'
  ]
};
const expanded = await jsonld.expand(compacted);

getting the output

console.log(JSON.stringify(expanded, null, 2));
/* Output:
[{
  "@type": ["http://schema.org/Organization"],
  "http://schema.org/sameAs": [{"@id": null}]
}]
*/

I would expect that the @id should not be null It seems like if the value starts with @ it is ignored https://github.com/digitalbazaar/jsonld.js/blob/983cd849f56180e2ee4552ca25dd52b293174830/lib/context.js#L986

Is this expected behaviour or a bug?