aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2014-11-17 05:33:01 +0000
committerStephen Blott2014-11-17 05:33:01 +0000
commit0ba67535c30c601d9f9d2a4158c3637132a976ce (patch)
tree1f5f2a5bd539181f66ce2ed74fb7db7aae4e2510
parent7b9c1017d8742b280774184e99743f4ae15e2777 (diff)
parent4a0f747fa2464b616fe45982c75f754b651b6c2f (diff)
downloadvimium-0ba67535c30c601d9f9d2a4158c3637132a976ce.tar.bz2
Merge pull request #1240 from smblott-github/exclusion-rule-default-pattern
Better default exclusion-rule pattern in popup
-rw-r--r--pages/popup.coffee16
1 files changed, 12 insertions, 4 deletions
diff --git a/pages/popup.coffee b/pages/popup.coffee
index 2ab97bef..99a4eb87 100644
--- a/pages/popup.coffee
+++ b/pages/popup.coffee
@@ -3,6 +3,17 @@ originalRule = undefined
originalPattern = undefined
originalPassKeys = undefined
+generateDefaultPattern = (url) ->
+ if /^https?:\/\/./.test url
+ # The common use case is to disable Vimium at the domain level.
+ # Generate "https?://www.example.com/*" from "http://www.example.com/path/to/page.html".
+ "https?:/" + url.split("/",3)[1..].join("/") + "/*"
+ else if /^[a-z]{3,}:\/\/./.test url
+ # Anything else which seems to be a URL.
+ url.split("/",3).join("/") + "/*"
+ else
+ url + "*"
+
reset = (initialize=false) ->
document.getElementById("optionsLink").setAttribute "href", chrome.runtime.getURL("pages/options.html")
chrome.tabs.getSelected null, (tab) ->
@@ -13,11 +24,8 @@ reset = (initialize=false) ->
originalPattern = originalRule.pattern
originalPassKeys = originalRule.passKeys
else
- # The common use case is to disable Vimium at the domain level.
- # This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html".
- domain = (tab.url.match(/[^\/]*\/\/[^\/]*\//) or tab.url) + "*"
originalRule = null
- originalPattern = domain
+ originalPattern = generateDefaultPattern tab.url
originalPassKeys = ""
patternElement = document.getElementById("popupPattern")
passKeysElement = document.getElementById("popupPassKeys")