Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 "use strict"; | 18 "use strict"; |
19 | 19 |
20 /** | 20 /** |
21 * Convert raw text into a regular expression string | |
Manish Jethani
2018/02/22 07:08:27
Sorry, for consistency, can we say "Converts" inst
hub
2018/02/22 14:07:49
Done.
| |
22 * @param {string} text the string to convert. | |
Manish Jethani
2018/02/22 07:08:27
Nit: seems like we generally don't add periods at
hub
2018/02/22 14:07:49
Done.
| |
23 * @return {string} regular expression representation of string match. | |
Manish Jethani
2018/02/22 07:08:28
"string match" seems to imply something, do you th
hub
2018/02/22 14:07:50
Done.
| |
24 */ | |
25 function textToRegExp(text) | |
26 { | |
27 return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); | |
28 } | |
29 | |
30 exports.textToRegExp = textToRegExp; | |
31 | |
32 /** | |
21 * Converts filter text into regular expression string | 33 * Converts filter text into regular expression string |
22 * @param {string} text as in Filter() | 34 * @param {string} text as in Filter() |
23 * @return {string} regular expression representation of filter text | 35 * @return {string} regular expression representation of filter text |
24 */ | 36 */ |
25 function filterToRegExp(text) | 37 function filterToRegExp(text) |
26 { | 38 { |
27 return text | 39 return text |
28 // remove multiple wildcards | 40 // remove multiple wildcards |
29 .replace(/\*+/g, "*") | 41 .replace(/\*+/g, "*") |
30 // remove anchors following separator placeholder | 42 // remove anchors following separator placeholder |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 start = i + 1; | 94 start = i + 1; |
83 } | 95 } |
84 } | 96 } |
85 } | 97 } |
86 | 98 |
87 selectors.push(selector.substring(start)); | 99 selectors.push(selector.substring(start)); |
88 return selectors; | 100 return selectors; |
89 } | 101 } |
90 | 102 |
91 exports.splitSelector = splitSelector; | 103 exports.splitSelector = splitSelector; |
OLD | NEW |