safe_url_check library
Utility library to check if an untrusted URL is broken or not.
This makes an HTTP HEAD
request after checking that the hostname does not
resolve to a private IPv4 address or local unique IPv6 address.
Example
import 'package:safe_url_check/safe_url_check.dart';
Future<void> main() async {
// Check if https://google.com is a broken URL.
final exists = await safeUrlCheck(
Uri.parse('https://google.com'),
userAgent: 'myexample/1.0.0 (+https://example.com)',
);
if (exists) {
print('The url: https://google.com is NOT broken');
}
}
Functions
-
safeUrlCheck(
Uri url, {int maxRedirects = 8, String userAgent = defaultUserAgent, HttpClient? client, RetryOptions retryOptions = const RetryOptions(maxAttempts: 3), Duration timeout = const Duration(seconds: 90)}) → Future< bool> -
Check if
url
is available, without allowing access to private networks.