Created
September 10, 2018 18:11
-
-
Save beaulac/2f06401ad3c662eb89b0dd3d503d6a90 to your computer and use it in GitHub Desktop.
Check IIS rewrite map duplicates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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