digitalbazaar / jsonld.js

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

expansion of `@id` doesn't work correctly if it contains a `:` and starts with a number #523

Closed ndr-brt closed 10 months ago

ndr-brt commented 1 year ago

The expansion seems to be buggy on version 8.2.0. If a @id value contains a ':' and it starts with a number it gets expanded in the wrong way

How to replicate

From the node repl:

> const jsonld = require('jsonld');

> jsonld.expand({'@id': 'a3:42', '@type': 'Any'}).then(result => console.log(result))
> [ { '@id': 'a3:42', '@type': [ 'Any' ] } ] // CORRECT

> jsonld.expand({'@id': '3:42', '@type': 'Any'}).then(result => console.log(result))
> [ { '@id': '42', '@type': [ 'Any' ] } ] // WRONG
davidlehn commented 10 months ago

Thanks. Addressed in https://github.com/digitalbazaar/jsonld.js/pull/533.