Merge pull request #9953 from alexstrat/fix-content-scripts-url-used-in-match

Fix page's URL used to test against content_scripts[].matches
This commit is contained in:
Kevin Sawicki 2017-07-14 14:16:42 -07:00 committed by GitHub
commit 03c8943997

View file

@ -5,9 +5,9 @@ const {runInThisContext} = require('vm')
// https://developer.chrome.com/extensions/match_patterns
const matchesPattern = function (pattern) {
if (pattern === '<all_urls>') return true
const regexp = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$')
return location.href.match(regexp)
const url = `${location.protocol}//${location.host}${location.pathname}`
return url.match(regexp)
}
// Run the code with chrome API integrated.