A lightweight library for checking if a url is down or not. Pretty useful while checking if the url inserted is correct one or fake one as normal url checking methods won't work.
Supports both Server and browser due to ohmyfetch
pnpm install is-url-online
or
npm install is-url-online
or
yarn add is-url-online
-
Promise based usage.
-
Works on both CommonJs and EsModule based libraries.
-
Smaller install size because of just one dependency.
-
Built using typescript.
-
Catches invalid URLs.
-
Actively maintained.
-
Automated Dependency update and publishing after successful tests.
-
Has helper methods to deal with extra usecases.
import { isUrlOnline } from "is-url-online";
await isUrlOnline("https://github.com/spa5k/is-url-online"); //-> true
await isUrlOnline("https://github.com/spa5k/notarepo"); //-> false
await isUrlOnline("notaurl"); //-> false
await isUrlOnline("ttps://github.com/spa5k/is-url-online abcd"); //-> false
//because of a space in middle.
This helper method will validate the URL string without checking it online.
import { isUrlString } from "is-url-online";
await isUrlString("https://google.com"); //-> true
await isUrlString("https://google.com/404ingURL"); //-> true
await isUrlString("notaurl"); //-> false
It uses URL module under the hood.
This helper method prepend https://
or http://
to humanized URLs like github.com
and localhost
import { prependHttp } from "is-url-online";
// HTTPS is enabled by default.
prependHttp({ url: "github.com" }); //-> https://github.com
prependHttp({ url: "github.com", https: false }); //-> http://github.com