From 6039f5678c61ecba1af890d88bf17981232d5203 Mon Sep 17 00:00:00 2001 From: Yigal Date: Tue, 6 Aug 2024 09:58:49 +0300 Subject: [PATCH] remove re2 dependency --- package.json | 6 ++---- src/utils.js | 15 ++------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index a76a2cf0..933fbc55 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "browser": { "./src/node/index.js": "./src/client.js", "./lib/node/index.js": "./lib/client.js", - "./test/support/server.js": "./test/support/blank.js", - "re2": false + "./test/support/server.js": "./test/support/blank.js" }, "bugs": { "url": "https://github.com/ladjs/superagent/issues" @@ -27,8 +26,7 @@ "formidable": "^3.5.1", "methods": "^1.1.2", "mime": "2.6.0", - "qs": "^6.11.0", - "re2": "^1.21.3" + "qs": "^6.11.0" }, "devDependencies": { "@babel/cli": "^7.20.7", diff --git a/src/utils.js b/src/utils.js index fc3514cc..fc1314c1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,14 +1,3 @@ -let RE2; -let hasRE2 = true; - -try { - RE2 = require('re2'); -} catch { - hasRE2 = false; -} - -const SafeRegExp = hasRE2 ? RE2 : RegExp; - /** * Return the mime type for the given `str`. @@ -125,7 +114,7 @@ exports.mixin = (target, source) => { */ exports.isGzipOrDeflateEncoding = (res) => { - return new SafeRegExp(/^\s*(?:deflate|gzip)\s*$/).test(res.headers['content-encoding']); + return new RegExp(/^\s*(?:deflate|gzip)\s*$/).test(res.headers['content-encoding']); }; /** @@ -135,5 +124,5 @@ exports.isGzipOrDeflateEncoding = (res) => { */ exports.isBrotliEncoding = (res) => { - return new SafeRegExp(/^\s*(?:br)\s*$/).test(res.headers['content-encoding']); + return new RegExp(/^\s*(?:br)\s*$/).test(res.headers['content-encoding']); };