| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 "use strict"; |
| 19 // used in the browser tests. See https://issues.adblockplus.org/ticket/4796 | |
| 20 | 19 |
| 21 /** | 20 /** |
| 22 * Converts filter text into regular expression string | 21 * Converts filter text into regular expression string |
| 23 * @param {string} text as in Filter() | 22 * @param {string} text as in Filter() |
| 24 * @return {string} regular expression representation of filter text | 23 * @return {string} regular expression representation of filter text |
| 25 */ | 24 */ |
| 26 function filterToRegExp(text) | 25 function filterToRegExp(text) |
| 27 { | 26 { |
| 28 return text | 27 return text |
| 29 // remove multiple wildcards | 28 // remove multiple wildcards |
| (...skipping 14 matching lines...) Expand all Loading... |
| 44 // process anchor at expression end | 43 // process anchor at expression end |
| 45 .replace(/\\\|$/, "$") | 44 .replace(/\\\|$/, "$") |
| 46 // remove leading wildcards | 45 // remove leading wildcards |
| 47 .replace(/^(\.\*)/, "") | 46 .replace(/^(\.\*)/, "") |
| 48 // remove trailing wildcards | 47 // remove trailing wildcards |
| 49 .replace(/(\.\*)$/, ""); | 48 .replace(/(\.\*)$/, ""); |
| 50 } | 49 } |
| 51 | 50 |
| 52 if (typeof exports != "undefined") | 51 if (typeof exports != "undefined") |
| 53 exports.filterToRegExp = filterToRegExp; | 52 exports.filterToRegExp = filterToRegExp; |
| OLD | NEW |