Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include.preload.js

Issue 5168731525218304: Issue 1441 - Let the browser resolve URLs instead doing it ourselve (Closed)
Patch Set: Created Sept. 25, 2014, 7:47 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include.postload.js ('k') | safari/ext/content.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.preload.js
===================================================================
--- a/include.preload.js
+++ b/include.preload.js
@@ -97,30 +97,11 @@
}
}
-// Converts relative to absolute URL
-// e.g.: foo.swf on http://example.com/whatever/bar.html
-// -> http://example.com/whatever/foo.swf
-function relativeToAbsoluteUrl(url)
+function resolveURL(url)
{
- // If URL is already absolute, don't mess with it
- if (!url || /^[\w\-]+:/i.test(url))
- return url;
-
- // Leading / means absolute path
- // Leading // means network path
- if (url[0] == '/')
- {
- if (url[1] == '/')
- return window.location.protocol + url;
- else
- return window.location.protocol + "//" + window.location.host + url;
- }
-
- // Remove filename and add relative URL to it
- var base = document.baseURI.match(/.+\//);
- if (!base)
- return document.baseURI + "/" + url;
- return base[0] + url;
+ var a = document.createElement("a");
+ a.href = url;
+ return a.href;
}
function init(document)
« no previous file with comments | « include.postload.js ('k') | safari/ext/content.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld