Skip to content

Commit 873ea92

Browse files
committed
perf: cache regex
1 parent 387d1c7 commit 873ea92

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class ProxyErrorHandler {
278278
this.req = null
279279
this.proxyReq = null
280280
this.errorHandler = null
281+
this.hpeExpr = /HPE_INVALID/
281282

282283
this._release = this._release.bind(this)
283284
this._handle = this._handle.bind(this)
@@ -294,7 +295,7 @@ class ProxyErrorHandler {
294295

295296
if (err.code === 'ECONNREFUSED' || err.code === 'ENOTFOUND') {
296297
err.statusCode = 503
297-
} else if (/HPE_INVALID/.test(err.code)) {
298+
} else if (this.hpeExpr.test(err.code)) {
298299
err.statusCode = 502
299300
} else if (err.code === 'ECONNRESET') {
300301
if (!this.proxyReq.aborted) {

0 commit comments

Comments
 (0)