From e179918a9602eab5edc8eda346b0cd3caba4ec77 Mon Sep 17 00:00:00 2001 From: eight Date: Mon, 18 Mar 2019 17:10:30 +0800 Subject: [PATCH] Fix: escape glob character --- popup/popup.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/popup/popup.js b/popup/popup.js index 64b04f68..ad612644 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -358,10 +358,15 @@ function styleExcluded({exclusions}, type) { } function getExcludeRule(type) { + const u = new URL(tabURL); if (type === 'domain') { - return new URL(tabURL).origin + '/*'; + return u.origin + '/*'; } - return tabURL + '*'; + return escapeGlob(u.origin + u.pathname) + '*'; +} + +function escapeGlob(text) { + return text.replace(/\*/g, '\\*'); } Object.assign(handleEvent, {