Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions check-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,30 @@ const checkLocalFile = (linkPath, filePath) => {
return null; // not a local file
};

// Check if URL is a localhost URL
const isLocalhostUrl = (url) => {
try {
const urlObj = new URL(url);
const hostname = urlObj.hostname.toLowerCase();

// Check for localhost patterns
return hostname === 'localhost' ||
hostname === '127.0.0.1' ||
hostname === '0.0.0.0' ||
hostname.endsWith('.localhost');
} catch (error) {
return false;
}
};

// Check external URL
const checkExternalUrl = async (url) => {
// Check if it's a localhost URL and skip validation
if (isLocalhostUrl(url)) {
console.log(` ➡️ ${url} (localhost - skipped)`);
return true;
}

try {
const response = await fetch(url, {
method: 'HEAD',
Expand Down
Loading