We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
RegExp.escape
1 parent 00a8377 commit 9e02b81Copy full SHA for 9e02b81
lib/internal/tls/wrap.js
@@ -27,6 +27,7 @@ const {
27
ObjectSetPrototypeOf,
28
ReflectApply,
29
RegExp,
30
+ RegExpEscape,
31
Symbol,
32
SymbolFor,
33
} = primordials;
@@ -1541,11 +1542,7 @@ Server.prototype.addContext = function(servername, context) {
1541
1542
throw new ERR_TLS_REQUIRED_SERVER_NAME();
1543
}
1544
- const re = new RegExp(`^${
1545
- servername
1546
- .replace(/([.^$+?\-\\[\]{}])/g, '\\$1')
1547
- .replaceAll('*', '[^.]*')
1548
- }$`);
+ const re = new RegExp(`^${RegExpEscape(servername).replace(/(?<=[^\\]|^)\\\*/g, '[^.]+')}$`);
1549
1550
const secureContext =
1551
context instanceof common.SecureContext ? context : tls.createSecureContext(context);
0 commit comments