Skip to content

Commit

Permalink
Ignore out-of-domain URLs that we cannot access
Browse files Browse the repository at this point in the history
  • Loading branch information
peol committed Apr 16, 2014
1 parent 084c42a commit bd017f9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/mqa.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
var callbacks = {};
var unbindCallbacks = {};
var queries = {};
var origin = location.origin || location.protocol + "//" + location.hostname + (location.port ? ":" + location.port: "");

/**
* Helper to convert any array-like object to an actual Array.
Expand Down Expand Up @@ -149,8 +150,10 @@
mqa.parse = function() {
log("Parsing CSS rules");
toArray(document.styleSheets).forEach(function(sheet) {
if(sheet.cssRules === null) {
return;
var isOutsideOfDomain = sheet.href && sheet.href.indexOf("/") !== 0 && sheet.href.indexOf(origin) !== 0;
if(isOutsideOfDomain || sheet.cssRules === null) {
// ignore sheets out-of-domain or without CSS rules:
return;
}
toArray(sheet.cssRules).forEach(function(rule) {
if (rule && rule instanceof CSSMediaRule) {
Expand Down

0 comments on commit bd017f9

Please sign in to comment.