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

Unified Diff: lib/common.js

Issue 29613805: Issue 6034 - :-abp-contains() accept a regular expression (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Some comments editing, Created Feb. 22, 2018, 2:05 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/content/elemHideEmulation.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | lib/content/elemHideEmulation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld