mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 20:32:07 +00:00
903c1110e0
[learn] sanitize the wiki content GitOrigin-RevId: c114bbd94479e926c0621953fe9c03f6d380a19d
35 lines
836 B
JavaScript
35 lines
836 B
JavaScript
const { checkSanitizeOptions } = require('./checkSanitizeOptions')
|
|
const { getAllPagesAndCache, scrapeAndCachePage } = require('./scrape')
|
|
|
|
async function main() {
|
|
const BASE_URL = process.argv.pop()
|
|
if (!BASE_URL.startsWith('http')) {
|
|
throw new Error(
|
|
'Usage: node scripts/learn/checkSanitize https://LEARN_WIKI'
|
|
)
|
|
}
|
|
|
|
const pages = await getAllPagesAndCache(BASE_URL)
|
|
|
|
for (const page of pages) {
|
|
try {
|
|
const parsed = await scrapeAndCachePage(BASE_URL, page)
|
|
|
|
const title = parsed.title
|
|
const text = parsed.text ? parsed.text['*'] : ''
|
|
|
|
checkSanitizeOptions(page, title, text)
|
|
} catch (e) {
|
|
console.error('---')
|
|
console.error(page, e)
|
|
throw e
|
|
}
|
|
}
|
|
}
|
|
|
|
if (require.main === module) {
|
|
main().catch(err => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|
|
}
|