Skip to content

Commit

Permalink
Merge pull request #1813 from yigaldviri/re2
Browse files Browse the repository at this point in the history
fix(brotli) remove re2 dependency
titanism authored Aug 13, 2024

Verified

This commit was signed with the committer’s verified signature.
slanterns Slanterns
2 parents 134cdd7 + 6039f56 commit edf0986
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
@@ -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",
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`.
@@ -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']);
};

0 comments on commit edf0986

Please sign in to comment.