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: Parse the regexp flag. Created Jan. 10, 2018, 6:01 a.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:
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
(no file at all)
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
20 /**
21 * Converts raw text into a regular expression string
22 * @param {string} text the string to convert
23 * @return {string} regular expression representation of the text
24 */
25 function textToRegExp(text)
26 {
27 return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
28 }
29
30 exports.textToRegExp = textToRegExp;
19 31
20 /** 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
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
LEFTRIGHT

Powered by Google App Engine
This is Rietveld