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

Delta Between Two Patch Sets: lib/common.js

Issue 29613805: Issue 6034 - :-abp-contains() accept a regular expression (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Left Patch Set: Address the regexp "escaping" Created Feb. 20, 2018, 5:49 p.m.
Right Patch Set: Some comments editing, Created Feb. 22, 2018, 2:05 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/content/elemHideEmulation.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 /**
Manish Jethani 2018/02/21 14:41:59 I would call this function "textToRegExp" to match
hub 2018/02/21 21:38:00 Done.
21 * Escape string to match to be a regular expression string 21 * Converts raw text into a regular expression string
22 * @param {string} s the string to search for. 22 * @param {string} text the string to convert
23 * @return {string} regular expression representation of string match. 23 * @return {string} regular expression representation of the text
24 */ 24 */
25 function escapeRegExp(s) 25 function textToRegExp(text)
26 { 26 {
27 return s.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); 27 return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
28 } 28 }
29 29
30 exports.escapeRegExp = escapeRegExp; 30 exports.textToRegExp = textToRegExp;
31 31
32 /** 32 /**
33 * Converts filter text into regular expression string 33 * Converts filter text into regular expression string
34 * @param {string} text as in Filter() 34 * @param {string} text as in Filter()
35 * @return {string} regular expression representation of filter text 35 * @return {string} regular expression representation of filter text
36 */ 36 */
37 function filterToRegExp(text) 37 function filterToRegExp(text)
38 { 38 {
39 return text 39 return text
40 // remove multiple wildcards 40 // remove multiple wildcards
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 start = i + 1; 94 start = i + 1;
95 } 95 }
96 } 96 }
97 } 97 }
98 98
99 selectors.push(selector.substring(start)); 99 selectors.push(selector.substring(start));
100 return selectors; 100 return selectors;
101 } 101 }
102 102
103 exports.splitSelector = splitSelector; 103 exports.splitSelector = splitSelector;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld