Index: lib/common.js |
=================================================================== |
--- a/lib/common.js |
+++ b/lib/common.js |
@@ -13,16 +13,28 @@ |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
"use strict"; |
/** |
+ * Converts raw text into a regular expression string |
+ * @param {string} text the string to convert |
+ * @return {string} regular expression representation of the text |
+ */ |
+function textToRegExp(text) |
+{ |
+ return text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&"); |
+} |
+ |
+exports.textToRegExp = textToRegExp; |
+ |
+/** |
* Converts filter text into regular expression string |
* @param {string} text as in Filter() |
* @return {string} regular expression representation of filter text |
*/ |
function filterToRegExp(text) |
{ |
return text |
// remove multiple wildcards |