diff --git a/core/matcher.js b/core/matcher.js new file mode 100644 index 0000000..702436f --- /dev/null +++ b/core/matcher.js @@ -0,0 +1,11 @@ +function doesUrlMatchBlackList(urlToMatch, dictionary){ + if(urlToMatch.indexOf('http') == -1){ + return false; + } + if(dictionary.urls[urlToMatch]){ + return true; + } + +} + +module.exports.doesUrlMatchBlackList = doesUrlMatchBlackList; diff --git a/core/spec/MatcherSpec.js b/core/spec/MatcherSpec.js new file mode 100644 index 0000000..d97af46 --- /dev/null +++ b/core/spec/MatcherSpec.js @@ -0,0 +1,26 @@ +describe("Matcher", function(){ + matcher = require('../matcher.js'); + var dictionary = {urls: + {"https://www.heroku.com/": { + "isDirect": false, + "parent": "https://salesforce.com/", + "source": "", + "description": "", + }, + "https://www.salesforce.com/": { + "isDirect": true, + "parent": "", + "source": "", + "description": "", + } + } + }; + it("should return false for any url that doesn't contain http: at the start", function(){ + expect(matcher.doesUrlMatchBlackList('ftp://abc.com/9.jpg', {})).toBe(false); + expect(matcher.doesUrlMatchBlackList('www.abc.com/9.jpg', {})).toBe(false); + }); + it("should return true for any url that does match the list", function(){ + expect(matcher.doesUrlMatchBlackList('https://www.heroku.com/', dictionary)).toBe(true); + expect(matcher.doesUrlMatchBlackList('https://www.salesforce.com/', dictionary)).toBe(true); + }); +}); diff --git a/core/spec/support/jasmine.json b/core/spec/support/jasmine.json new file mode 100644 index 0000000..a5f2932 --- /dev/null +++ b/core/spec/support/jasmine.json @@ -0,0 +1,9 @@ +{ + "spec_dir": "spec", + "spec_files": [ + "**/*[sS]pec.js" + ], + "helpers": [ + "helpers/**/*.js" + ] +}