Skip to content

Commit c87be77

Browse files
committed
Optimize definition @id and iri comparison.
1 parent 5d30de3 commit c87be77

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

js/jsonld.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5562,13 +5562,13 @@ function _compactIri(activeCtx, iri, value, relativeTo, reverse) {
55625562
var choice = null;
55635563
for(var term in activeCtx.mappings) {
55645564
var definition = activeCtx.mappings[term];
5565-
// skip terms with colons, they can't be prefixes
5566-
if(definition && definition._termHasColon) {
5565+
// skip null definitions and terms with colons, they can't be prefixes
5566+
if(!definition || definition._termHasColon) {
55675567
continue;
55685568
}
55695569
// skip entries with @ids that are not partial matches
5570-
if(!definition ||
5571-
definition['@id'] === iri || iri.indexOf(definition['@id']) !== 0) {
5570+
if(!(iri.length > definition['@id'].length &&
5571+
iri.indexOf(definition['@id']) === 0)) {
55725572
continue;
55735573
}
55745574

0 commit comments

Comments
 (0)