Created
September 25, 2015 12:26
-
-
Save normanzb/0e9b67d1dc4939d657e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Apply path matching | |
var path = d.location.pathname, | |
refMatch = document.referrer.match(/.{8}[^/]*(\/[^?]+)/), | |
ref = refMatch ? refMatch[1] : null, | |
isPathMatch = function(pattern) { | |
var p = new RegExp((pattern[0] == "/" ? "^" : "") + pattern, "i"); | |
return p.test(path); | |
}, | |
toArray = function(v){ return _.isArray(v) ? v : [v] }; | |
if (criteria.path && !_.any(toArray(criteria.path), isPathMatch)) { | |
return; | |
} | |
if (criteria.not_path && _.any(toArray(criteria.not_path), isPathMatch)) { | |
return; | |
} | |
path = ref; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment