Skip to content

Instantly share code, notes, and snippets.

@getkey
Created September 2, 2021 18:01
Show Gist options
  • Save getkey/fdf6fff2abbaab77fcc1c5b2602f48d5 to your computer and use it in GitHub Desktop.
Save getkey/fdf6fff2abbaab77fcc1c5b2602f48d5 to your computer and use it in GitHub Desktop.
Small tool to find out if some URL are loaded twice. Takes a HAR file as an entry
const fs = require('fs');
const har = JSON.parse(fs.readFileSync(process.argv[2]));
har.log.entries
.map(({ request }) => request.url)
.reduce((watchlist, url) => {
const seenTimes = watchlist.get(url) || 0;
watchlist.set(url, seenTimes + 1)
return watchlist;
}, new Map())
.forEach((seenTimes, url) => {
if (seenTimes > 1) {
console.log(url, 'seen', seenTimes, 'time(s).');
}
});
console.log('Done.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment