Skip to content

Instantly share code, notes, and snippets.

@beaulac
Created September 10, 2018 18:11
Show Gist options
  • Save beaulac/2f06401ad3c662eb89b0dd3d503d6a90 to your computer and use it in GitHub Desktop.
Save beaulac/2f06401ad3c662eb89b0dd3d503d6a90 to your computer and use it in GitHub Desktop.
Check IIS rewrite map duplicates
'use strict';
const fs = require('fs');
const readline = require('readline');
const [, , filename] = process.argv;
if (!filename) {
throw Error('NO FILENAME SPECIFIED');
}
const rl = readline.createInterface({
input: fs.createReadStream(filename, 'utf8')
});
let lineNumber = 0;
const originals = {};
rl.on('line', line => {
lineNumber++;
const [, originalUrl] = /key="(.+?)"/.exec(line) || [];
if (!originalUrl) {
return;
}
if (originalUrl in originals) {
console.log('Duplicate of ' + originals[originalUrl] + ' at line ' + lineNumber, originalUrl);
}
originals[originalUrl] = lineNumber;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment