« get me outta code hell

Be less verbose with wildcard representations - interactive-bgm - Browser extension that adds background music based on the site you're browsing
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-03-24 12:04:18 -0300
committerFlorrie <towerofnix@gmail.com>2019-03-24 12:04:18 -0300
commitb143ccbcec4770a9aafbca60538d57883a15e555 (patch)
tree32acd8a951110cc01b20f1bb63f92bd03ad3df6f
parentfddd404bad102579da3e3e1e850755aa4da19a83 (diff)
Be less verbose with wildcard representations
-rw-r--r--extension/popup/main.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/extension/popup/main.js b/extension/popup/main.js
index 1dc39f4..5b95db8 100644
--- a/extension/popup/main.js
+++ b/extension/popup/main.js
@@ -127,11 +127,11 @@ function loadTrackList(opts) {
     });
 }
 
-function getWildcardRepresentation(rule, urlString = rule.sourceURL) {
+function getWildcardRepresentation(rule, verbose = false) {
     const {hostnameMatch, pathnameMatch} = rule;
-    const {hostnameParts, pathnameParts} = getURLParts(urlString);
+    const {hostnameParts, pathnameParts} = getURLParts(rule.sourceURL);
 
-    let string = 'http(s)://';
+    let string = verbose ? 'http(s)://' : '';
 
     if (hostnameMatch.length !== hostnameParts.length) {
         if (hostnameMatch.length > 0) {
@@ -180,7 +180,7 @@ function loadRuleScreen({tab, rule, saveRule, deleteRule}) {
     };
 
     const updateWildcardRepresentation = () => {
-        const string = getWildcardRepresentation(rule, rule.sourceURL);
+        const string = getWildcardRepresentation(rule, true);
 
         const el = document.getElementById('wildcard-representation');
         while (el.firstChild) {
@@ -297,7 +297,7 @@ function loadRuleList({tab, siteSettings, selectRule}) {
         const li = document.createElement('li');
 
         li.classList.add('rule');
-        li.dataset.wildcardRepresentation = getWildcardRepresentation(rule, rule.sourceURL || tab.url);
+        li.dataset.wildcardRepresentation = getWildcardRepresentation(rule);
         li.appendChild(document.createTextNode(li.dataset.wildcardRepresentation));
         li.title = li.dataset.wildcardRepresentation;