Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pagexray

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pagexray - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

5

bin/index.js

@@ -8,2 +8,3 @@ #!/usr/bin/env node

const minimist = require('minimist');
const packageInfo = require('../package');

@@ -14,3 +15,5 @@ const argv = minimist(process.argv.slice(2), {

if (argv.help || !argv._[0]) {
if (argv.version) {
console.log(`${packageInfo.version}`);
} else if (argv.help || !argv._[0]) {
console.log(' Convert a HAR file to a (better) page summary.');

@@ -17,0 +20,0 @@ console.log(' Usage: pagexray [options] pathToHarFile\n');

# CHANGELOG - PageXray
version 2.0.0 2017-11-10
------------------------
### Added
* We moved to the NodeJS 8.x since it is now LTS.
### Fixed
* Har files that includes the same url loaded with different http version (h1 vs h2) are now parsed correctly.
* Handle redirects to paths (e.g. /foo) and convert to absolute urls.
version 1.0.1 2017-10-15

@@ -9,2 +18,5 @@ ------------------------

## Added
* Get the PageXray version with --version.
version 1.0.0 2017-08-26

@@ -11,0 +23,0 @@ ------------------------

26

lib/index.js

@@ -80,15 +80,21 @@ 'use strict';

if (!testedPages[entry.pageref]) {
const redirects = util.getFinalURL(entry, har);
const httpVersion =
redirects.chain.length === 0
? entry.response.httpVersion
: util.getEntryByURL(har.log.entries, redirects.url).response
.httpVersion;
const redirects = util.getRedirectTarget(
entry.request.url,
har,
entry.pageref
);
const targetEntry = util.getEntryByURL(
har.log.entries,
redirects.finalUrl,
entry.pageref
);
const httpVersion = targetEntry.response.httpVersion;
currentPage = {
url: entry.request.url,
meta: { browser: {}, startedDateTime: entry.startedDateTime },
finalUrl: redirects.url,
baseDomain: util.getHostname(redirects.url),
documentRedirects:
redirects.chain.length === 0 ? 0 : redirects.chain.length - 1,
finalUrl: redirects.finalUrl,
baseDomain: util.getHostname(redirects.finalUrl),
documentRedirects: redirects.chain.length,
redirectChain: redirects.chain,

@@ -95,0 +101,0 @@ transferSize: 0,

@@ -67,37 +67,44 @@ 'use strict';

* and check if it is redirected, and then report the last URL
* @param {Object} harEntry The har entry that is the first occurrence.
* @param {string} url The url to check.
* @param {Object} har The har.
* @returns {string} the last url in the redirect chain.
* @param {Object} pageId
* @returns {Object} final url and redirect chain.
* @throws if har doesn't have exactly one page
*/
getFinalURL: (harEntry, har) => {
let url = harEntry.request.url;
let chain = [url];
const redirections = har.log.entries.reduce((results, entry) => {
results[entry.request.url] = entry.response.redirectURL || '';
return results;
}, {});
getRedirectTarget: (url, har, pageId) => {
const chain = [];
const redirections = har.log.entries
.filter(entry => {
return pageId !== undefined ? entry.pageref === pageId : true;
})
.reduce((results, entry) => {
let destination = entry.response.redirectURL;
if (destination) {
if (destination.startsWith('/')) {
destination = urlParser.resolve(entry.request.url, destination);
}
results[entry.request.url] = destination;
}
return results;
}, {});
let nextUrl = redirections[url];
while (nextUrl && nextUrl !== '') {
url = nextUrl;
nextUrl = redirections[url];
while (nextUrl) {
chain.push(nextUrl);
nextUrl = redirections[nextUrl];
}
// we don't have a redirect
if (chain.length === 1) {
chain = [];
}
const finalUrl = chain.length > 0 ? chain[chain.length - 1] : url;
return {
url,
finalUrl,
chain
};
},
getEntryByURL(entries, url) {
for (let entry of entries) {
if (entry.request.url === url) {
return entry;
}
}
getEntryByURL(entries, url, pageId) {
return entries.find(
entry => entry.request.url === url && entry.pageref === pageId
);
}
};
{
"name": "pagexray",
"version": "1.0.1",
"version": "2.0.0",
"description": "Xray your HAR file and know all about the page",

@@ -46,3 +46,3 @@ "keywords": [

"engines": {
"node": ">=6.10.3"
"node": ">=8.7.0"
},

@@ -49,0 +49,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc