Permalink
Browse files

Fixed checkBaseURL to properly generate URLs given a <base> tag

  • Loading branch information...
1 parent e735025 commit 7564a2fe204e7d9312c450bae52131da0276733e Harry Schmidt committed Jan 16, 2014
Showing with 7 additions and 5 deletions.
  1. +7 −5 cross-domain/respond.proxy.js
@@ -66,13 +66,15 @@
win.setTimeout(checkFrameName, 500);
}
+ // http://stackoverflow.com/a/472729
function checkBaseURL(href) {
- if (baseElem && href.indexOf(baseElem.href) === -1) {
- bref = (/\/$/).test(baseElem.href) ? baseElem.href : (baseElem.href + "/");
- href = bref + href;
- }
+ var el = document.createElement('div'),
+ escapedURL = href.split('&').join('&amp;').
+ split('<').join('&lt;').
+ split('"').join('&quot;');
- return href;
+ el.innerHTML = '<a href="' + escapedURL + '">x</a>';
+ return el.firstChild.href;
}
function checkRedirectURL() {

0 comments on commit 7564a2f

Please sign in to comment.