Skip to content

Commit

Permalink
Adding fix for loading stylesheets from multiple domains (My patch on…
Browse files Browse the repository at this point in the history
…ly supports loading from one declared domain as of yet). Non-matching domains now silently fail.
  • Loading branch information
doctyper committed Jun 4, 2011
1 parent d94e62b commit c5f1847
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions respond.src.js
Expand Up @@ -27,6 +27,7 @@
isExtRegExp = /^([a-zA-Z]+?:(\/\/)?(www\.)?)/,
proxyURL = (doc.getElementById("respond-proxy") || {}).href,
redirectURL = (doc.getElementById("respond-redirect") || win.location).href,
matchDomain,
proxyInterval,
thisRequest,
iframe,
Expand All @@ -39,6 +40,10 @@
i = 0,
//vars for loop:
sheet, href, media, isCSS;

if (proxyURL) {
matchDomain = proxyURL.match(/^[^\.]+\.[a-z]{2,4}/);
}

for( ; i < sl; i++ ){
sheet = sheets[ i ],
Expand All @@ -50,7 +55,7 @@
if( !!href && isCSS && !parsedSheets[ href ] ){
if( !isExtRegExp.test( href )
|| href.replace( RegExp.$1, "" ).split( "/" )[0] === host
|| proxyURL && win.top === win.self ){
|| proxyURL && win.top === win.self && ~ href.indexOf(matchDomain)){
requestQueue.push( {
href: href,
media: media
Expand Down Expand Up @@ -223,7 +228,7 @@
},
//tweaked Ajax functions from Quirksmode
ajax = function( url, callback ) {
if (proxyURL && redirectURL && isExtRegExp.test(url)) {
if (proxyURL && ~ url.indexOf(matchDomain) && isExtRegExp.test(url)) {
var refNode = docElem.firstElementChild || docElem.firstChild;

if (!iframe) {
Expand Down

0 comments on commit c5f1847

Please sign in to comment.