A simple TypeScript utility to check if a string is a valid URL and if the URL is reachable (via HTTP/HTTPS request).
- Type-safe and minimal
- Works with both HTTP and HTTPS
- Supports CommonJS and ES modules
- Includes both format validation and URL reachability check
npm install valid-url-ts
import { isUrl } from 'valid-url-ts';
console.log(isUrl('https://google.com')); // true
console.log(isUrl('not a url')); // false
import { isValidUrl } from 'valid-url-ts';
isValidUrl('https://google.com', (err, isValid) => {
if (err) {
console.error('Error:', err);
} else {
console.log('Is reachable:', isValid);
}
});
import { isValidUrlAsync } from 'valid-url-ts';
(async () => {
const valid = await isValidUrlAsync('https://google.com');
console.log(valid); // true or false
})();
npm run build
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions, issues and feature requests are welcome! Feel free to check the issues page.
If you find this package helpful, please consider giving it a star on GitHub!