From 7f4c829e4d33f7f7c2e3755b9eadcaa9d6094448 Mon Sep 17 00:00:00 2001 From: Jan Miksovsky Date: Mon, 12 May 2014 13:58:49 -0700 Subject: [PATCH] If a resource is served with a "Location" header, redirected imports resolve their paths relative to the resource' redirected location rather than the original requested location. --- src/Loader.js | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Loader.js b/src/Loader.js index acdad6e..7b9bb26 100644 --- a/src/Loader.js +++ b/src/Loader.js @@ -90,8 +90,8 @@ this.receive(url, elt, null, body); }.bind(this), 0); } else { - var receiveXhr = function(err, resource) { - this.receive(url, elt, err, resource); + var receiveXhr = function(err, resource, redirectedUrl) { + this.receive(url, elt, err, resource, redirectedUrl); }.bind(this); xhr.load(url, receiveXhr); // TODO(sorvell): blocked on) @@ -109,16 +109,25 @@ */ } }, - receive: function(url, elt, err, resource) { + receive: function(url, elt, err, resource, redirectedUrl) { this.cache[url] = resource; var $p = this.pending[url]; + if ( redirectedUrl ) { + this.cache[redirectedUrl] = resource; + $p = $p.concat(this.pending[redirectedUrl]); + } for (var i=0, l=$p.length, p; (i