Skip to content

Commit 0013f50

Browse files
Merge pull request #61 from justindhillon/false-negitives
Fix False Negitives
2 parents c5e154a + 8db8aac commit 0013f50

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

checkLink.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,28 @@ export async function checkLink(link: string): Promise<boolean> {
1616
"X-Amzn-Trace-Id": "Root=1-659f58c5-4de24ef7384486270161f185"
1717
}
1818
};
19+
20+
const falsePositives: number[] = [999, 429, 403];
1921

2022
try {
2123
await axios.head(link, params);
2224
} catch (err: any) {
2325
// If false positive, return false
24-
if (err.response.status === 999) return false;
25-
if (err.response.status === 429) return false;
26+
if (falsePositives.includes(err.response.status)) return false;
2627

2728
// If HEAD is not allowed try GET
2829
if (err.response.status === 405) {
2930
try {
3031
await axios.get(link, params);
3132
} catch (error: any) {
32-
// If method not allowed, return false
33-
if (error.response.status === 405) return false;
34-
33+
// If false positive, return false
34+
if (falsePositives.includes(err.response.status)) return false;
35+
3536
return true;
3637
}
3738
}
39+
40+
return true;
3841
}
3942

4043
return false;

0 commit comments

Comments
 (0)