[Pkg-mozext-commits] [adblock-plus] 06/52: Issue 1675 - Use String.trim() to strip leading and trailing whitespaces

David Prévot taffit at moszumanska.debian.org
Thu Jan 22 21:43:43 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository adblock-plus.

commit fffd82d8fdfe21fe7cd8e6587d647fa0bf8884a1
Author: Sebastian Noack <sebastian at adblockplug.org>
Date:   Mon Dec 8 18:23:48 2014 +0100

    Issue 1675 - Use String.trim() to strip leading and trailing whitespaces
    
    --HG--
    extra : rebase_source : b6df4094c5b2cffeb8905b744822051094baca1b
---
 chrome/content/ui/filters-subscriptionactions.js | 2 +-
 chrome/content/ui/subscriptionSelection.js       | 4 ++--
 lib/filterClasses.js                             | 4 ++--
 lib/ui.js                                        | 8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/chrome/content/ui/filters-subscriptionactions.js b/chrome/content/ui/filters-subscriptionactions.js
index 7cedc27..189a785 100644
--- a/chrome/content/ui/filters-subscriptionactions.js
+++ b/chrome/content/ui/filters-subscriptionactions.js
@@ -444,7 +444,7 @@ var TitleEditor =
     if (save)
     {
       newTitle = subscriptionNode.getElementsByClassName("titleEditor")[0].value;
-      newTitle = newTitle.replace(/^\s+/, "").replace(/\s+$/, "");
+      newTitle = newTitle.trim();
     }
 
     let subscription = Templater.getDataForNode(subscriptionNode).subscription
diff --git a/chrome/content/ui/subscriptionSelection.js b/chrome/content/ui/subscriptionSelection.js
index 3fdcc18..ac97b69 100644
--- a/chrome/content/ui/subscriptionSelection.js
+++ b/chrome/content/ui/subscriptionSelection.js
@@ -239,7 +239,7 @@ function validateURL(url)
 {
   if (!url)
     return null;
-  url = url.replace(/^\s+/, "").replace(/\s+$/, "");
+  url = url.trim();
 
   // Is this a file path?
   try {
@@ -266,7 +266,7 @@ function addSubscription()
     return false;
   }
 
-  let title = E("title").value.replace(/^\s+/, "").replace(/\s+$/, "");
+  let title = E("title").value.trim();
   if (!title)
     title = url;
 
diff --git a/lib/filterClasses.js b/lib/filterClasses.js
index 3e067de..dd9853e 100644
--- a/lib/filterClasses.js
+++ b/lib/filterClasses.js
@@ -147,13 +147,13 @@ Filter.normalize = function(/**String*/ text) /**String*/
   if (/^\s*!/.test(text))
   {
     // Don't remove spaces inside comments
-    return text.replace(/^\s+/, "").replace(/\s+$/, "");
+    return text.trim();
   }
   else if (Filter.elemhideRegExp.test(text))
   {
     // Special treatment for element hiding filters, right side is allowed to contain spaces
     let [, domain, separator, selector] = /^(.*?)(#\@?#?)(.*)$/.exec(text);
-    return domain.replace(/\s/g, "") + separator + selector.replace(/^\s+/, "").replace(/\s+$/, "");
+    return domain.replace(/\s/g, "") + separator + selector.trim();
   }
   else
     return text.replace(/\s/g, "");
diff --git a/lib/ui.js b/lib/ui.js
index 748a003..3a82618 100644
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -951,12 +951,12 @@ let UI = exports.UI =
       mainSubscriptionURL = null;
 
     // Trim spaces in title and URL
-    title = title.replace(/^\s+/, "").replace(/\s+$/, "");
-    url = url.replace(/^\s+/, "").replace(/\s+$/, "");
+    title = title.trim();
+    url = url.trim();
     if (mainSubscriptionURL)
     {
-      mainSubscriptionTitle = mainSubscriptionTitle.replace(/^\s+/, "").replace(/\s+$/, "");
-      mainSubscriptionURL = mainSubscriptionURL.replace(/^\s+/, "").replace(/\s+$/, "");
+      mainSubscriptionTitle = mainSubscriptionTitle.trim();
+      mainSubscriptionURL = mainSubscriptionURL.trim();
     }
 
     // Verify that the URL is valid

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git



More information about the Pkg-mozext-commits mailing list