OLD | NEW |
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 Loading... |
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 Loading... |
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 }; |
OLD | NEW |