diff --git a/jsonld.php b/jsonld.php index 2fad5fa..fb28231 100644 --- a/jsonld.php +++ b/jsonld.php @@ -1,7 +1,7 @@ {'@base'}; + if($base === null) { + $rval->{'@base'} = jsonld_parse_url($options['base']); + } + else if(!is_string($base)) { + throw new JsonLdException( + 'Invalid JSON-LD syntax; the value of "@base" in a ' . + '@context must be a string or null.', + 'jsonld.SyntaxError', array('context' => $ctx)); + } + else if(!self::_isAbsoluteIri($base)) { + throw new JsonLdException( + 'Invalid JSON-LD syntax; the value of "@base" in a ' . + '@context must be an absolute IRI.', + 'jsonld.SyntaxError', array('context' => $ctx)); + } + else { + $rval->{'@base'} = $base; + } + $defined->{'@base'} = true; + } + // handle @vocab if(property_exists($ctx, '@vocab')) { $value = $ctx->{'@vocab'};