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

har-online

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

har-online - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

18

har-online.js
var GitHubApi = require("github");
var Promise = require("bluebird");

@@ -13,3 +12,7 @@ var github = new GitHubApi({

function harUrl(harObject) {
function viewerUrl(fileUrl) {
return "http://www.softwareishard.com/har/viewer?inputUrl=" + fileUrl;
}
function harUrl(harObject, cb) {
// Gists require a filename, so we use a timestamp

@@ -24,6 +27,9 @@ var filename = Date.now().toString();

};
var createGist = Promise.promisify(github.gists.create);
return createGist(gistOptions).then(function (res) {
var gist = res.files[filename].raw_url;
return 'http://www.softwareishard.com/har/viewer?inputUrl=' + gist;
github.gists.create(gistOptions, function (err, res) {
if (err) {
return cb(err);
} else {
var gist = res.files[filename].raw_url;
return cb(null, viewerUrl(gist));
}
});

@@ -30,0 +36,0 @@ }

#!/usr/bin/env node
var harUrl = require("./har-online.js").harUrl;
var Promise = require("bluebird");
var validUrl = require("valid-url");
var fs = Promise.promisifyAll(require("fs"));
var request = Promise.promisify(require("request"));
function success(res) {
console.log(res);
process.exit(0);
}
function failure() {
console.error("Invalid URL or HAR file!");
process.exit(1);
}
function missingFile(err) {
console.error("File doesn't exist: " + err.path);
process.exit(1);
}
function tryJson(str) {

@@ -32,24 +12,30 @@ try {

function harFromInput(input) {
function harFromInput(input, cb) {
var json = tryJson(input);
if (validUrl.isUri(input)) {
return request(input).spread(function (res, body) {
return harUrl(JSON.parse(body));
});
} else if (json) {
return harUrl(json);
if (json) {
return harUrl(json, cb);
} else {
return fs.readFileAsync(input).then(function (file) {
return harUrl(JSON.parse(file));
}, missingFile).then(success, failure);
return cb("Invalid HAR file");
}
}
var stdinSize = fs.fstatSync(process.stdin.fd).size;
var input;
if (stdinSize > 0) {
input = fs.readSync(process.stdin.fd, stdinSize)[0];
} else {
input = process.argv[process.argv.length - 1];
}
harFromInput(input).then(success, failure);
process.stdin.setEncoding("utf-8");
var input = [];
process.stdin.on("readable", function () {
var chunk = process.stdin.read();
if (chunk != null) {
input.push(chunk);
}
});
process.stdin.on("end", function () {
harFromInput(input.join(""), function (err, url) {
if (err) {
console.error(err);
process.exit(1);
} else {
console.log(url);
process.exit(0);
}
});
});
{
"name": "har-online",
"version": "0.0.2",
"version": "0.1.0",
"description": "View HAR files at http://www.softwareishard.com/har/viewer/",

@@ -21,7 +21,4 @@ "main": "index.js",

"dependencies": {
"github": "0.2.4",
"bluebird": "2.9.30",
"valid-url": "1.0.9",
"request": "2.58.0"
"github": "0.2.4"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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