mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-10 00:33:10 +00:00
20 lines
563 B
JavaScript
20 lines
563 B
JavaScript
/**
|
|
* Utility to check if a URL loads successfully within a timeout
|
|
*/
|
|
export async function urlLoads(url, timeoutMs = 5000) {
|
|
try {
|
|
const controller = new AbortController();
|
|
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
const response = await fetch(url, {
|
|
method: 'HEAD',
|
|
signal: controller.signal,
|
|
cache: 'no-cache',
|
|
});
|
|
clearTimeout(timeoutId);
|
|
return response.ok;
|
|
}
|
|
catch {
|
|
return false;
|
|
}
|
|
}
|
|
//# sourceMappingURL=urlLoads.js.map
|