Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/filterClasses.js

Issue 5325266087837696: Issue 1675 - Use String.trim() to strip leading and trailing whitespaces (Firefox) (Closed)
Patch Set: Created Dec. 8, 2014, 5:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/content/ui/subscriptionSelection.js ('k') | lib/ui.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 { 140 {
141 if (!text) 141 if (!text)
142 return text; 142 return text;
143 143
144 // Remove line breaks and such 144 // Remove line breaks and such
145 text = text.replace(/[^\S ]/g, ""); 145 text = text.replace(/[^\S ]/g, "");
146 146
147 if (/^\s*!/.test(text)) 147 if (/^\s*!/.test(text))
148 { 148 {
149 // Don't remove spaces inside comments 149 // Don't remove spaces inside comments
150 return text.replace(/^\s+/, "").replace(/\s+$/, ""); 150 return text.trim();
151 } 151 }
152 else if (Filter.elemhideRegExp.test(text)) 152 else if (Filter.elemhideRegExp.test(text))
153 { 153 {
154 // Special treatment for element hiding filters, right side is allowed to co ntain spaces 154 // Special treatment for element hiding filters, right side is allowed to co ntain spaces
155 let [, domain, separator, selector] = /^(.*?)(#\@?#?)(.*)$/.exec(text); 155 let [, domain, separator, selector] = /^(.*?)(#\@?#?)(.*)$/.exec(text);
156 return domain.replace(/\s/g, "") + separator + selector.replace(/^\s+/, ""). replace(/\s+$/, ""); 156 return domain.replace(/\s/g, "") + separator + selector.trim();
157 } 157 }
158 else 158 else
159 return text.replace(/\s/g, ""); 159 return text.replace(/\s/g, "");
160 } 160 }
161 161
162 /** 162 /**
163 * Class for invalid filters 163 * Class for invalid filters
164 * @param {String} text see Filter() 164 * @param {String} text see Filter()
165 * @param {String} reason Reason why this filter is invalid 165 * @param {String} reason Reason why this filter is invalid
166 * @constructor 166 * @constructor
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 function ElemHideException(text, domains, selector) 940 function ElemHideException(text, domains, selector)
941 { 941 {
942 ElemHideBase.call(this, text, domains, selector); 942 ElemHideBase.call(this, text, domains, selector);
943 } 943 }
944 exports.ElemHideException = ElemHideException; 944 exports.ElemHideException = ElemHideException;
945 945
946 ElemHideException.prototype = 946 ElemHideException.prototype =
947 { 947 {
948 __proto__: ElemHideBase.prototype 948 __proto__: ElemHideBase.prototype
949 }; 949 };
OLDNEW
« no previous file with comments | « chrome/content/ui/subscriptionSelection.js ('k') | lib/ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld