@@ -42,13 +42,14 @@ func NewContext(values map[string]interface{}, options *JsonLdOptions) *Context
42
42
termDefinitions : make (map [string ]interface {}),
43
43
}
44
44
45
+ context .values ["@base" ] = options .Base
46
+
45
47
if values != nil {
46
48
for k , v := range values {
47
49
context .values [k ] = v
48
50
}
49
51
}
50
52
51
- context .values ["@base" ] = options .Base
52
53
context .values ["processingMode" ] = options .ProcessingMode
53
54
54
55
return context
@@ -185,6 +186,7 @@ func (c *Context) parse(localContext interface{}, remoteContexts []string, parsi
185
186
if vocabValue == nil {
186
187
delete (result .values , "@vocab" )
187
188
} else if vocabString , isString := vocabValue .(string ); isString {
189
+
188
190
if IsAbsoluteIri (vocabString ) {
189
191
result .values ["@vocab" ] = vocabValue
190
192
} else if vocabString == "" {
@@ -194,7 +196,11 @@ func (c *Context) parse(localContext interface{}, remoteContexts []string, parsi
194
196
return nil , NewJsonLdError (InvalidVocabMapping , "@vocab is empty but @base is not specified" )
195
197
}
196
198
} else {
197
- return nil , NewJsonLdError (InvalidVocabMapping , "@vocab must be an absolute IRI" )
199
+ expandedVocab , err := result .ExpandIri (vocabString , true , true , nil , nil )
200
+ if err != nil {
201
+ return nil , err
202
+ }
203
+ result .values ["@vocab" ] = expandedVocab
198
204
}
199
205
} else {
200
206
return nil , NewJsonLdError (InvalidVocabMapping , "@vocab must be a string or null" )
0 commit comments