Skip to content

Commit b0f9bf2

Browse files
committed
Allow fragment identifiers with ':'
This change fixes w3c/json-ld-syntax#66
1 parent 79f315f commit b0f9bf2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ld/api_compact.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (api *JsonLdApi) Compact(activeCtx *Context, activeProperty string, element
119119
} else {
120120
compactedValue = compactedValues
121121
}
122-
122+
123123
compValArray, isArray := compactedValue.([]interface{})
124124
AddValue(result, alias, compactedValue, isArray && (len(compValArray) == 0 || isTypeContainer), true)
125125
continue

ld/context.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,13 +712,18 @@ func (c *Context) ExpandIri(value string, relative bool, vocab bool, context map
712712
}
713713
}
714714
// 4.4)
715+
// If active context contains a term definition for prefix, return the result of concatenating
716+
// the IRI mapping associated with prefix and suffix.
715717
if termDef, hasPrefix := c.termDefinitions[prefix]; hasPrefix {
716718
termDefMap := termDef.(map[string]interface{})
717719
return termDefMap["@id"].(string) + suffix, nil
720+
} else if IsAbsoluteIri(value) {
721+
// Otherwise, if the value has the form of an absolute IRI, return it
722+
return value, nil
718723
}
719-
// 4.5)
720-
return value, nil
724+
// Otherwise, it is a relative IRI
721725
}
726+
722727
// 5)
723728
if vocabValue, containsVocab := c.values["@vocab"]; vocab && containsVocab {
724729
return vocabValue.(string) + value, nil

0 commit comments

Comments
 (0)