From cb037115856a9e00eeab8311a851d84a621b3f1d Mon Sep 17 00:00:00 2001 From: Dave Longley Date: Thu, 28 Feb 2013 16:03:11 -0500 Subject: [PATCH] Add @base support. --- jsonld.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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'};