-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1b9c44
commit 7da3701
Showing
4 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { writeFile } from 'node:fs/promises'; | ||
|
||
async function checkUrl(url) { | ||
try { | ||
await fetch(url, { | ||
method: 'HEAD', | ||
redirect: 'follow', | ||
}); | ||
return { url, working: true }; | ||
} catch { | ||
return { url, working: false }; | ||
} | ||
} | ||
|
||
async function main() { | ||
const urls = [ | ||
'http://youthexplosion4christ.com/', | ||
'https://youthexplosion4christ.com/', | ||
// Your URLs here | ||
]; | ||
|
||
const results = await Promise.all(urls.map(checkUrl)); | ||
|
||
const deadLinks = results.filter((r) => !r.working).map((r) => r.url); | ||
|
||
// await writeFile('dead-links.json', JSON.stringify(deadLinks, null, 2)); | ||
console.log(`Found ${deadLinks.length} dead links`); | ||
console.log(JSON.stringify(deadLinks)); | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error); | ||
}); |