From 14bc46dd72ff286c66089f03a2eb489ac3b99fdc Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 3 Nov 2016 11:32:06 -0700 Subject: [PATCH] benchmark,lib,test,tools: remove unneeded . escape The `.` character does not need to be escaped when it appears inside a regular expression character class. This removes instances of unnecessary escapes of the `.` character. This also removes a few unnecessary escapes of the `(` and `)` characters within character classes too. PR-URL: https://github.com/nodejs/node/pull/9449 Reviewed-By: Roman Reiss Reviewed-By: Colin Ihrig Reviewed-By: Minwoo Jung Reviewed-By: James Snell --- lib/_tls_wrap.js | 4 ++-- test/parallel/test-repl.js | 2 +- tools/doc/json.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 7efe42ab46ca22..056499b723f0d0 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -916,8 +916,8 @@ Server.prototype.addContext = function(servername, context) { } var re = new RegExp('^' + - servername.replace(/([\.^$+?\-\\[\]{}])/g, '\\$1') - .replace(/\*/g, '[^\.]*') + + servername.replace(/([.^$+?\-\\[\]{}])/g, '\\$1') + .replace(/\*/g, '[^.]*') + '$'); this._contexts.push([re, tls.createSecureContext(context).context]); }; diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 23a5a3d59fa3cb..d79247153bd4de 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -72,7 +72,7 @@ function error_test() { if (read_buffer !== client_unix.expect) { var expect = client_unix.expect; if (expect === prompt_multiline) - expect = /[\.]{3} /; + expect = /[.]{3} /; assert.ok(read_buffer.match(expect)); console.error('match'); } diff --git a/tools/doc/json.js b/tools/doc/json.js index a194c7f7231423..a782c54028d756 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -545,12 +545,12 @@ function deepCopy_(src) { // these parse out the contents of an H# tag var eventExpr = /^Event(?::|\s)+['"]?([^"']+).*$/i; var classExpr = /^Class:\s*([^ ]+).*?$/i; -var propExpr = /^(?:property:?\s*)?[^\.]+\.([^ \.\(\)]+)\s*?$/i; -var braceExpr = /^(?:property:?\s*)?[^\.\[]+(\[[^\]]+\])\s*?$/i; +var propExpr = /^(?:property:?\s*)?[^.]+\.([^ .()]+)\s*?$/i; +var braceExpr = /^(?:property:?\s*)?[^.\[]+(\[[^\]]+\])\s*?$/i; var classMethExpr = - /^class\s*method\s*:?[^\.]+\.([^ \.\(\)]+)\([^\)]*\)\s*?$/i; + /^class\s*method\s*:?[^.]+\.([^ .()]+)\([^)]*\)\s*?$/i; var methExpr = - /^(?:method:?\s*)?(?:[^\.]+\.)?([^ \.\(\)]+)\([^\)]*\)\s*?$/i; + /^(?:method:?\s*)?(?:[^.]+\.)?([^ .()]+)\([^)]*\)\s*?$/i; var newExpr = /^new ([A-Z][a-zA-Z]+)\([^\)]*\)\s*?$/; var paramExpr = /\((.*)\);?$/;