Update to latest jsonld.js.
authorDave Longley <dlongley@digitalbazaar.com>
Fri, 04 Oct 2013 14:50:25 -0400
changeset 2023 8ff97032c94d
parent 2022 9c3fa82c344a
child 2024 0fd990485fc3
Update to latest jsonld.js.
playground/jsonld.js
--- a/playground/jsonld.js	Fri Oct 04 11:49:11 2013 -0700
+++ b/playground/jsonld.js	Fri Oct 04 14:50:25 2013 -0400
@@ -1455,6 +1455,7 @@
  * @return the XMLHttpRequest document loader.
  */
 jsonld.documentLoaders.xhr = function(options) {
+  var rlink = /(^|(\r\n))link:/i;
   options = options || {};
   var cache = new jsonld.DocumentCache();
   var loader = function(url, callback) {
@@ -1474,9 +1475,12 @@
     req.onload = function(e) {
       var doc = {contextUrl: null, documentUrl: url, document: req.response};
 
-      // handle Link Header
+      // handle Link Header (avoid unsafe header warning by existence testing)
       var contentType = req.getResponseHeader('Content-Type');
-      var linkHeader = req.getResponseHeader('Link');
+      var linkHeader;
+      if(rlink.test(req.getAllResponseHeaders())) {
+        linkHeader = req.getResponseHeader('Link');
+      }
       if(linkHeader && contentType !== 'application/ld+json') {
         // only 1 related link header permitted
         linkHeader = jsonld.parseLinkHeader(linkHeader)[LINK_HEADER_REL];