From 73e8769b1f3bd8927c2c6a1a2a731ff5351a5d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Lach=C3=A8ze?= Date: Fri, 7 Jul 2017 04:14:36 +0200 Subject: [PATCH 1/2] content_scripts[].matches use the URL without hash part --- lib/renderer/content-scripts-injector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/renderer/content-scripts-injector.js b/lib/renderer/content-scripts-injector.js index e4a801110f62..0bb8ca6893c2 100644 --- a/lib/renderer/content-scripts-injector.js +++ b/lib/renderer/content-scripts-injector.js @@ -5,9 +5,9 @@ const {runInThisContext} = require('vm') // https://developer.chrome.com/extensions/match_patterns const matchesPattern = function (pattern) { if (pattern === '') 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. From 969c74b8866a49a26aad352eaad967bac58ff0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20Lach=C3=A8ze?= Date: Mon, 10 Jul 2017 23:50:59 +0200 Subject: [PATCH 2/2] Use es6 string templating --- lib/renderer/content-scripts-injector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/renderer/content-scripts-injector.js b/lib/renderer/content-scripts-injector.js index 0bb8ca6893c2..7fbe3f5ef02c 100644 --- a/lib/renderer/content-scripts-injector.js +++ b/lib/renderer/content-scripts-injector.js @@ -6,7 +6,7 @@ const {runInThisContext} = require('vm') const matchesPattern = function (pattern) { if (pattern === '') return true const regexp = new RegExp('^' + pattern.replace(/\*/g, '.*') + '$') - const url = location.protocol + '//' + location.host + location.pathname + const url = `${location.protocol}//${location.host}${location.pathname}` return url.match(regexp) }