@@ -5,10 +5,6 @@ var querystring = require('querystring');
55var util = require ( "util" ) ;
66var url = require ( "url" ) ;
77
8- // Hack, but I don't want to make *any* changes to xregexp-all.js
9- eval ( fs . readFileSync ( 'xregexp-all.js' ) . toString ( ) ) ;
10-
11-
128function h ( unsafe )
139{
1410 if ( unsafe == null )
@@ -104,11 +100,6 @@ function serveTestPost(request, response)
104100 } ) ;
105101}
106102
107- function makeRegExp ( use_xregexp , str_regex , str_options )
108- {
109- return use_xregexp ? new XRegExp ( str_regex , str_options ) : new RegExp ( str_regex , str_options )
110- }
111-
112103function serveTest ( query , response )
113104{
114105 response . writeHead ( 200 , {
@@ -168,7 +159,6 @@ function serveTest(query, response)
168159 var replacement = 'replacement' in params ? params [ 'replacement' ] [ 0 ] : null ;
169160 var str_options = "" ;
170161 var options = 'option' in params ? params [ 'option' ] : null ;
171- var use_xregexp = 'engine' in params && params [ 'engine' ] [ 0 ] == 'xregexp' ;
172162 var global = false ;
173163 if ( options != null && options . length > 0 )
174164 {
@@ -189,22 +179,6 @@ function serveTest(query, response)
189179 {
190180 str_options += "i" ;
191181 }
192- else if ( use_xregexp && option == "dotall" )
193- {
194- str_options += 's' ;
195- }
196- else if ( use_xregexp && option == "comment" )
197- {
198- str_options += 'x' ;
199- }
200- else if ( use_xregexp && option == "explicitcapture" )
201- {
202- str_options += 'n' ;
203- }
204- else if ( use_xregexp && option == "sticky" )
205- {
206- str_options += 'y' ;
207- }
208182 else
209183 {
210184 retVal [ "warning" ] = ( 'warning' in retVal ? retVal [ 'warning' ] : '' ) + "Invalid option '" + option + "'" ;
@@ -240,14 +214,14 @@ function serveTest(query, response)
240214
241215 try
242216 {
243- compileTest = makeRegExp ( use_xregexp , str_regex , str_options ) ;
217+ compileTest = new RegExp ( str_regex , str_options ) ;
244218 }
245219 catch ( err )
246220 {
247221 html . push ( '<div class="alert alert-error">Error: ' ) ;
248222 html . push ( h ( err . message ) ) ;
249223 html . push ( "</div>" ) ;
250- response . write ( JSON . stringify ( { "success" : true , "message" : "unable to create " + ( use_xregexp ? "XRegExp" : " RegExp" ) + " object", "html" : html . join ( "" ) } ) ) ;
224+ response . write ( JSON . stringify ( { "success" : true , "message" : "unable to create RegExp object" , "html" : html . join ( "" ) } ) ) ;
251225 response . end ( ) ;
252226 return ;
253227 }
@@ -293,11 +267,11 @@ function serveTest(query, response)
293267 html . push ( "</td>\n" ) ;
294268
295269 html . push ( '\t\t\t<td>' ) ;
296- html . push ( h ( input . replace ( makeRegExp ( use_xregexp , str_regex , str_options ) , replacement == null ? "" : replacement ) ) ) ;
270+ html . push ( h ( input . replace ( new RegExp ( str_regex , str_options ) , replacement == null ? "" : replacement ) ) ) ;
297271 html . push ( "</td>\n" ) ;
298272
299273 html . push ( '\t\t\t<td>' ) ;
300- var splits = input . split ( makeRegExp ( use_xregexp , str_regex , str_options ) ) ;
274+ var splits = input . split ( new RegExp ( str_regex , str_options ) ) ;
301275 for ( var split = 0 ; split < splits . length ; split ++ )
302276 {
303277 html . push ( "[" ) ;
@@ -309,10 +283,10 @@ function serveTest(query, response)
309283 html . push ( "</td>\n" ) ;
310284
311285 html . push ( '\t\t\t<td>' ) ;
312- html . push ( makeRegExp ( use_xregexp , str_regex , str_options ) . test ( input ) ? "true" : "false" ) ; // can't use the same object twice
286+ html . push ( new RegExp ( str_regex , str_options ) . test ( input ) ? "true" : "false" ) ; // can't use the same object twice
313287 html . push ( "</td>\n" ) ;
314288
315- var regex = makeRegExp ( use_xregexp , str_regex , str_options ) ;
289+ var regex = new RegExp ( str_regex , str_options ) ;
316290 var result = regex . exec ( input ) ;
317291 if ( result == null )
318292 {
0 commit comments