r75616 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75615‎ | r75616 | r75617 >
Date:15:32, 28 October 2010
Author:catrope
Status:ok
Tags:
Comment:
Remove RegExp.escape() in favor of String.prototype.escapeRE()
Modified paths:
  • /trunk/extensions/WikiEditor/modules/ext.wikiEditor.dialogs.js (modified) (history)
  • /trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
@@ -1,10 +1,4 @@
22 /**
3 - * Extend the RegExp object with an escaping function
4 - * From http://simonwillison.net/2006/Jan/20/escape/
5 - */
6 -RegExp.escape = function( s ) { return s.replace(/([.*+?^${}()|\/\\[\]])/g, '\\$1'); };
7 -
8 -/**
93 * Dialog Module for wikiEditor
104 */
115 ( function( $ ) { $.wikiEditor.modules.dialogs = {
Index: trunk/extensions/WikiEditor/modules/ext.wikiEditor.dialogs.js
@@ -507,7 +507,7 @@
508508 open: function() {
509509 // Cache the articlepath regex
510510 $(this).data( 'articlePathRegex', new RegExp(
511 - '^' + RegExp.escape( wgServer + wgArticlePath )
 511+ '^' + ( wgServer + wgArticlePath ).escapeRE()
512512 .replace( /\\\$1/g, '(.*)' ) + '$'
513513 ) );
514514 // Pre-fill the text fields based on the current selection
@@ -980,7 +980,7 @@
981981 flags += 'g';
982982 }
983983 if ( !isRegex ) {
984 - searchStr = RegExp.escape( searchStr );
 984+ searchStr = searchStr.escapeRE();
985985 }
986986 try {
987987 var regex = new RegExp( searchStr, flags );

Status & tagging log