Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Thu, 28 Feb 2013 16:43:13 -0500
changeset 1360 64f71d511536
parent 1359 12b96298e413
child 1361 fae8fd05bccf
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Thu Feb 28 16:20:16 2013 -0500
+++ b/playground/jsonld.js	Thu Feb 28 16:43:13 2013 -0500
@@ -4520,7 +4520,7 @@
     }
   }
 
-  path = '/' + segments.join('/');
+  path = segments.join('/');
 
   // add query and hash
   if(rel.query) {
@@ -4530,11 +4530,20 @@
     path += rel.hash;
   }
 
-  var rval = (base.protocol || '') + '//';
-  if(base.auth) {
-    rval += base.auth + '@';
-  }
-  rval += authority + path;
+  var rval = '';
+  if(base.href === '') {
+    if(rel.href.indexOf('//') === 0) {
+      rval += '//';
+    }
+    rval += path;
+  }
+  else {
+    rval += (base.protocol || '') + '//';
+    if(base.auth) {
+      rval += base.auth + '@';
+    }
+    rval += authority + '/' + path;
+  }
 
   return rval;
 }
@@ -4553,6 +4562,11 @@
     base.pathname = base.pathname || '';
   }
 
+  // base is empty
+  if(base.href === '') {
+    return iri;
+  }
+
   // establish base root
   var root = (base.protocol || '') + '//';
   if(base.auth) {
@@ -4567,6 +4581,7 @@
 
   // remove root from IRI and parse remainder
   var rel = jsonld.url.parse(iri.substr(root.length));
+  rel.pathname = rel.pathname || '';
 
   // remove path segments that match
   var baseSegments = base.pathname.split('/');