Initial commit
commit
ab621b13fd
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
@ -0,0 +1,14 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const bhttp = require("bhttp");
|
||||||
|
const Promise = require("bluebird");
|
||||||
|
|
||||||
|
const extractGarbage = require("./lib/extract-garbage");
|
||||||
|
|
||||||
|
return Promise.try(() => {
|
||||||
|
return bhttp.get(process.argv[2]);
|
||||||
|
}).then((response) => {
|
||||||
|
let snippets = extractGarbage(response.body.toString());
|
||||||
|
|
||||||
|
console.log(snippets.map(snippet => snippet.garbage).join(""));
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function extractGarbage(body) {
|
||||||
|
let snippetRegex = /(^|[^\n]+\n)([0-9a-f]+)(\s*)($|\n[^\n]+)/g;
|
||||||
|
|
||||||
|
let snippets = [];
|
||||||
|
let match;
|
||||||
|
|
||||||
|
while (match = snippetRegex.exec(body)) {
|
||||||
|
snippets.push({before: match[1], garbage: match[2], whitespace: match[3], after: match[4]});
|
||||||
|
snippetRegex.lastIndex -= match[4].length; // To allow overlapping matches
|
||||||
|
}
|
||||||
|
|
||||||
|
return snippets;
|
||||||
|
};
|
@ -0,0 +1,21 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const Promise = require("bluebird");
|
||||||
|
const bhttp = require("bhttp");
|
||||||
|
const chalk = require("chalk");
|
||||||
|
const repeatString = require("repeat-string");
|
||||||
|
|
||||||
|
const extractGarbage = require("./lib/extract-garbage");
|
||||||
|
|
||||||
|
Promise.map(urls, (url) => {
|
||||||
|
return Promise.try(() => {
|
||||||
|
return bhttp.get(process.argv[2]);
|
||||||
|
}).then((response) => {
|
||||||
|
let snippets = extractGarbage(response.body.toString());
|
||||||
|
|
||||||
|
snippets.forEach((snippet) => {
|
||||||
|
console.log(`${snippet.before}${chalk.red.bold(snippet.garbage)}${repeatString(".", snippet.whitespace.length)}${snippet.after}`);
|
||||||
|
console.log("---------");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "garbagechecker",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "Sven Slootweg",
|
||||||
|
"license": "WTFPL",
|
||||||
|
"dependencies": {
|
||||||
|
"bhttp": "^1.2.4",
|
||||||
|
"bluebird": "^3.5.0",
|
||||||
|
"chalk": "^1.1.3",
|
||||||
|
"repeat-string": "^1.6.1"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue