Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(brotli) remove re2 dependency #1813

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']);
};
Loading