aws-log-replay
Advanced tools
Comparing version 2.6.1 to 2.7.0-dev7
42
index.js
@@ -12,2 +12,4 @@ var request = require('requestretry'); | ||
const allowedMethods = ['GET', 'HEAD']; | ||
/** | ||
@@ -25,3 +27,3 @@ * decode a path according to cloudfront character encoding spec | ||
else | ||
return match; | ||
return match; | ||
}); | ||
@@ -49,8 +51,15 @@ } | ||
} | ||
if (!path) return callback(); | ||
if (keepReferer && parts[9] && parts[9] !== '-') { | ||
var referer = parts[9]; | ||
} | ||
// get Referer | ||
if (path && referer) generatePath.push([path, referer]); | ||
else generatePath.push(path); | ||
const method = parts[5]; | ||
// get Referer & method | ||
if (method && allowedMethods.some((m) => method.includes(m))) { | ||
const obj = { path, method }; | ||
if (referer) obj.referer = referer; | ||
generatePath.push(obj); | ||
} | ||
} | ||
@@ -63,4 +72,8 @@ } else if (type.toLowerCase() == 'lb') { | ||
path = url.parse(path).path; | ||
const method = parts.length === 18 ? parts[11] : parts[12]; | ||
if (!path) return callback(); | ||
generatePath.push(path); | ||
// get request method | ||
// usually it is stored as "GET, regex will help remove the non-alphabetical characters | ||
if (method && allowedMethods.some((m) => method.includes(m))) generatePath.push({ path, method: method.match(/[a-zA-Z]+/g)[0] }); | ||
} | ||
@@ -86,9 +99,8 @@ callback(); | ||
var pathname, referer; | ||
if (typeof data === 'object') { | ||
pathname = data[0]; | ||
referer = data[1]; | ||
if (referer && typeof referer !== 'string') referer = referer.toString('utf8'); | ||
} else { | ||
pathname = data; | ||
} | ||
const method = data['method']; | ||
referer = data['referer']; | ||
if (referer && typeof referer !== 'string') referer = referer.toString('utf8'); | ||
pathname = data['path']; | ||
if (typeof pathname !== 'string') pathname = pathname.toString('utf8'); | ||
@@ -109,5 +121,9 @@ if (!pathname || pathname.indexOf('/') !== 0) return callback(); | ||
if (referer) { | ||
requestOptions.headers = { referer: referer }; | ||
requestOptions.headers = { referer }; | ||
} | ||
if (method) { | ||
requestOptions.method = method; | ||
} | ||
request(requestOptions, (err, res, body) => { | ||
@@ -114,0 +130,0 @@ if (err) return callback(err); |
@@ -8,3 +8,3 @@ { | ||
"engines": { | ||
"node": ">=8.10.0" | ||
"node": ">=14" | ||
}, | ||
@@ -14,3 +14,3 @@ "name": "aws-log-replay", | ||
"author": "Mapbox", | ||
"version": "2.6.1", | ||
"version": "2.7.0-dev7", | ||
"dependencies": { | ||
@@ -33,3 +33,3 @@ "agentkeepalive": "^3.5.1", | ||
"documentation": "2.0.x", | ||
"eslint": "^3.11.1", | ||
"eslint": "^4.19.1", | ||
"request": "^2.87.0", | ||
@@ -36,0 +36,0 @@ "tape": "3.5.x" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
151
13627
12
2