mirror of
https://github.com/alibaba/anyproxy.git
synced 2025-08-04 21:39:04 +00:00
use jest for CI
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
export function curlify(recordDetail) {
|
||||
const headers = { ...recordDetail.reqHeader };
|
||||
const acceptEncoding = headers['Accept-Encoding'] || headers['accept-encoding'];
|
||||
// escape reserve character in url
|
||||
const url = recordDetail.url.replace(/([\[\]])/g, '\\$1');
|
||||
const curlified = ['curl', `'${url}'`];
|
||||
module.exports = {
|
||||
curlify(recordDetail) {
|
||||
const headers = { ...recordDetail.reqHeader };
|
||||
const acceptEncoding = headers['Accept-Encoding'] || headers['accept-encoding'];
|
||||
// escape reserve character in url
|
||||
const url = recordDetail.url.replace(/([\[\]])/g, '\\$1');
|
||||
const curlified = ['curl', `'${url}'`];
|
||||
|
||||
if (recordDetail.method.toUpperCase() !== 'GET') {
|
||||
curlified.push('-X', recordDetail.method);
|
||||
if (recordDetail.method.toUpperCase() !== 'GET') {
|
||||
curlified.push('-X', recordDetail.method);
|
||||
}
|
||||
|
||||
Object.keys(headers).forEach((key) => {
|
||||
curlified.push('-H', `'${key}: ${headers[key]}'`);
|
||||
});
|
||||
|
||||
if (recordDetail.reqBody) {
|
||||
curlified.push('-d', `'${recordDetail.reqBody}'`);
|
||||
}
|
||||
|
||||
if (/deflate|gzip/.test(acceptEncoding)) {
|
||||
curlified.push('--compressed');
|
||||
}
|
||||
|
||||
return curlified.join(' ');
|
||||
}
|
||||
|
||||
Object.keys(headers).forEach((key) => {
|
||||
curlified.push('-H', `'${key}: ${headers[key]}'`);
|
||||
});
|
||||
|
||||
if (recordDetail.reqBody) {
|
||||
curlified.push('-d', `'${recordDetail.reqBody}'`);
|
||||
}
|
||||
|
||||
if (/deflate|gzip/.test(acceptEncoding)) {
|
||||
curlified.push('--compressed');
|
||||
}
|
||||
|
||||
return curlified.join(' ');
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user