Skip to content

Commit

Permalink
Merge pull request #96 from justindhillon/increase-accuraccy
Browse files Browse the repository at this point in the history
Fix false positives and negitives
  • Loading branch information
justindhillon authored Apr 8, 2024
2 parents 1a77bfc + 9bd1d3f commit de4dfba
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions checkLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,24 @@ export async function checkLink(link: string): Promise<boolean> {
const url = new URL(link);
if (ignoredURLs.has(url.host))
return false;
if (url.host.indexOf("api.") !== -1)
return false

try {
await axios.head(link, params);
return false;
} catch (err: any) {
console.log(err.response);
// If false positive, return false
if (ignoredCodes.has(err.response.status))
if (err.response?.status && ignoredCodes.has(err.response.status))
return false;

// Head request is not allowed, make get request
try {
await axios.get(link, params);
return false;
} catch (err: any) {
if (ignoredCodes.has(err.response.status))
if (err.response?.status && ignoredCodes.has(err.response.status))
return false;
}

Expand Down

0 comments on commit de4dfba

Please sign in to comment.