Skip to content

Commit

Permalink
remove re2 dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
yigaldviri committed Aug 11, 2024
1 parent 134cdd7 commit 6039f56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
Expand Down
15 changes: 2 additions & 13 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down Expand Up @@ -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']);
};

/**
Expand All @@ -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']);
};

0 comments on commit 6039f56

Please sign in to comment.