99import java .util .LinkedHashMap ;
1010import java .util .List ;
1111import java .util .Map ;
12+ import java .util .regex .Pattern ;
1213
1314import com .github .jsonldjava .core .JsonLdError .Error ;
1415import com .github .jsonldjava .utils .JsonLdUrl ;
@@ -25,6 +26,7 @@ public class Context extends LinkedHashMap<String, Object> {
2526
2627 private static final long serialVersionUID = 2894534897574805571L ;
2728
29+ private static final Pattern URL_PATTERN = Pattern .compile ("^https?://.*$" , Pattern .CASE_INSENSITIVE );
2830 private JsonLdOptions options ;
2931 private Map <String , Object > termDefinitions ;
3032 public Map <String , Object > inverse = null ;
@@ -141,7 +143,6 @@ && getTermDefinition(activeProperty).containsKey(JsonLdConsts.LANGUAGE)
141143 * @throws JsonLdError
142144 * If there is an error parsing the contexts.
143145 */
144- @ SuppressWarnings ("unchecked" )
145146 public Context parse (Object localContext , List <String > remoteContexts ) throws JsonLdError {
146147 if (remoteContexts == null ) {
147148 remoteContexts = new ArrayList <String >();
@@ -187,7 +188,11 @@ private Context parse(Object localContext, final List<String> remoteContexts,
187188 }
188189 // 3.2)
189190 else if (context instanceof String ) {
190- String uri = (String ) result .get (JsonLdConsts .BASE );
191+ String uri = null ;
192+ // @base is ignored when processing remote contexts, https://github.com/jsonld-java/jsonld-java/issues/304
193+ if (!URL_PATTERN .matcher (context .toString ()).matches ()) {
194+ uri = (String ) result .get (JsonLdConsts .BASE );
195+ }
191196 uri = JsonLdUrl .resolve (uri , (String ) context );
192197 // 3.2.2
193198 if (remoteContexts .contains (uri )) {
0 commit comments