Skip to content

Commit 6cbb617

Browse files
Merge pull request #13 from justindhillon/localhost
Fixed https://localhost:3000 false positive
2 parents 37e8896 + d3c4099 commit 6cbb617

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

bin/scan/writeBrokenLinks.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ const linkCheck = require('link-check');
22
const fs = require('fs');
33
const path = require('path');
44

5+
function isLocalhostUrl(url) {
6+
const localhostRegex = /^(https?:\/\/)?localhost(:\d+)?(\/|$)/i;
7+
return localhostRegex.test(url);
8+
}
9+
510
// data is string
611
// path is <file/directory path>
712
// Writes data to identical path in "output"
@@ -32,6 +37,7 @@ function writeToFile(data, PATH) {
3237
async function writeBrokenLinks(links, PATH) {
3338
for (const link of links) {
3439
await new Promise(r => setTimeout(r, 2000));
40+
if (isLocalhostUrl(link)) { continue }
3541
linkCheck(link, function (err, result) {
3642
if (err) {
3743
console.error('Error: failed to validate', link);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "link-inspector",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "A npx package that automatically scans files and directories broken links.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)