File tree Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -230,28 +230,21 @@ function format(f) {
230230 return str ;
231231}
232232
233- var debugs = { } ;
234- var debugEnviron ;
235-
236- const regExpSpecialChars = / [ | \\ { } ( ) [ \] ^ $ + ? . ] / g;
237-
238- function stringToRegExp ( string ) {
239- // Escape special chars except wildcard.
240- string = string . replace ( regExpSpecialChars , '\\$&' ) ;
241- // Transform wildcard to "match anything"
242- string = string . replace ( / \* / g, '.*' ) ;
243- return new RegExp ( `^${ string } $` ) ;
233+ const debugs = { } ;
234+ let debugEnvRegex = / ^ $ / ;
235+ if ( process . env . NODE_DEBUG ) {
236+ let debugEnv = process . env . NODE_DEBUG ;
237+ debugEnv = debugEnv . replace ( / [ | \\ { } ( ) [ \] ^ $ + ? . ] / g, '\\$&' )
238+ . replace ( / \* / g, '.*' )
239+ . replace ( / , / g, '$|^' )
240+ . toUpperCase ( ) ;
241+ debugEnvRegex = new RegExp ( `^${ debugEnv } $` , 'i' ) ;
244242}
245243
246244function debuglog ( set ) {
247- if ( debugEnviron === undefined ) {
248- debugEnviron = Array . from ( new Set (
249- ( process . env . NODE_DEBUG || '' ) . split ( ',' ) . map ( ( s ) => s . toUpperCase ( ) ) ) ) ;
250- debugEnviron = debugEnviron . map ( stringToRegExp ) ;
251- }
252245 set = set . toUpperCase ( ) ;
253246 if ( ! debugs [ set ] ) {
254- if ( debugEnviron . some ( ( name ) => name . test ( set ) ) ) {
247+ if ( debugEnvRegex . test ( set ) ) {
255248 var pid = process . pid ;
256249 debugs [ set ] = function ( ) {
257250 var msg = exports . format . apply ( exports , arguments ) ;
You can’t perform that action at this time.
0 commit comments