diff --git a/src/HTMLImports.js b/src/HTMLImports.js index dc2e8e3..c9f2fb4 100644 --- a/src/HTMLImports.js +++ b/src/HTMLImports.js @@ -288,7 +288,7 @@ var path = { return url; } url = this.compressUrl(this.urlToPath(baseUrl) + url); - if (relativeToDocument && !this.isAbsUrl(url)) { + if (relativeToDocument) { url = path.makeRelPath(path.getDocumentUrl(document), url); } return url; @@ -325,6 +325,10 @@ var path = { var s, t; s = this.compressUrl(inSource).split("/"); t = this.compressUrl(inTarget).split("/"); + // bail if target is not relative to source + if (!s.length || s[0] !== t[0]) { + return inTarget; + } while (s.length && s[0] === t[0]){ s.shift(); t.shift(); diff --git a/test/html/imports/abs.html b/test/html/imports/abs.html new file mode 100644 index 0000000..657c769 --- /dev/null +++ b/test/html/imports/abs.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/html/path.html b/test/html/path.html index 55df8cc..59dce3a 100644 --- a/test/html/path.html +++ b/test/html/path.html @@ -6,6 +6,15 @@ +