strip-wayback-toolbar
Version:
Strip wayback toolbar from archived html
17 lines (13 loc) • 527 B
JavaScript
module.exports = html => {
if (typeof html !== 'string') {
throw new TypeError('strip-wayback-toolbar expected a string')
}
return html
.replace(assetRegex, '<head>')
.replace(noHeadAssetRegex, '')
.replace(toolbarRegex, '')
}
const assetRegex = /<head>((.|\n)*)<\!-- End Wayback Rewrite JS Include -->/
const noHeadAssetRegex = /^((.|\n)*)<\!-- End Wayback Rewrite JS Include -->/
const toolbarRegex = /<\!-- BEGIN WAYBACK TOOLBAR INSERT -->((.|\n)*)<\!-- END WAYBACK TOOLBAR INSERT -->/