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

Side by Side Diff: lib/common.js

Issue 29375915: Issue 4878 - Start using ESLint for adblockpluscore (Closed)
Patch Set: Fix Cu.imports in synchronizer.js that I missed previously Created March 14, 2017, 9:03 a.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 | « README.md ('k') | lib/coreUtils.js » ('j') | lib/synchronizer.js » ('J')
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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 // We are currently limited to ECMAScript 5 in this file, because it is being 18 // We are currently limited to ECMAScript 5 in this file, because it is being
19 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796 19 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796
20 20
21 /** 21 /**
22 * Converts filter text into regular expression string 22 * Converts filter text into regular expression string
23 * @param {String} text as in Filter() 23 * @param {string} text as in Filter()
24 * @return {String} regular expression representation of filter text 24 * @return {string} regular expression representation of filter text
25 */ 25 */
26 function filterToRegExp(text) 26 function filterToRegExp(text)
27 { 27 {
28 return text 28 return text
29 // remove multiple wildcards 29 // remove multiple wildcards
30 .replace(/\*+/g, "*") 30 .replace(/\*+/g, "*")
31 // remove anchors following separator placeholder 31 // remove anchors following separator placeholder
32 .replace(/\^\|$/, "^") 32 .replace(/\^\|$/, "^")
33 // escape special symbols 33 // escape special symbols
34 .replace(/\W/g, "\\$&") 34 .replace(/\W/g, "\\$&")
35 // replace wildcards by .* 35 // replace wildcards by .*
36 .replace(/\\\*/g, ".*") 36 .replace(/\\\*/g, ".*")
37 // process separator placeholders (all ANSI characters but alphanumeric 37 // process separator placeholders (all ANSI characters but alphanumeric
38 // characters and _%.-) 38 // characters and _%.-)
39 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\x6 0\\x7B-\\x7F]|$)") 39 .replace(/\\\^/g, "(?:[\\x00-\\x24\\x26-\\x2C\\x2F\\x3A-\\x40\\x5B-\\x5E\\x6 0\\x7B-\\x7F]|$)")
40 // process extended anchor at expression start 40 // process extended anchor at expression start
41 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?") 41 .replace(/^\\\|\\\|/, "^[\\w\\-]+:\\/+(?!\\/)(?:[^\\/]+\\.)?")
42 // process anchor at expression start 42 // process anchor at expression start
43 .replace(/^\\\|/, "^") 43 .replace(/^\\\|/, "^")
44 // process anchor at expression end 44 // process anchor at expression end
45 .replace(/\\\|$/, "$") 45 .replace(/\\\|$/, "$")
46 // remove leading wildcards 46 // remove leading wildcards
47 .replace(/^(\.\*)/, "") 47 .replace(/^(\.\*)/, "")
48 // remove trailing wildcards 48 // remove trailing wildcards
49 .replace(/(\.\*)$/, ""); 49 .replace(/(\.\*)$/, "");
50 } 50 }
51 51
52 if (typeof exports != "undefined") 52 if (typeof exports != "undefined")
53 exports.filterToRegExp = filterToRegExp; 53 exports.filterToRegExp = filterToRegExp;
OLDNEW
« no previous file with comments | « README.md ('k') | lib/coreUtils.js » ('j') | lib/synchronizer.js » ('J')

Powered by Google App Engine
This is Rietveld