validateUrl static method
void
validateUrl(
- String url
)
Implementation
static void validateUrl(String url) {
if (url.isEmpty) {
throw const FittorException('URL cannot be empty');
}
try {
final uri = Uri.parse(url);
if (!uri.hasScheme) {
throw const FittorException('URL must have a scheme (http or https)');
}
if (uri.scheme != 'http' && uri.scheme != 'https') {
throw const FittorException('URL scheme must be http or https');
}
if (!uri.hasAuthority) {
throw const FittorException('URL must have a host');
}
} catch (e) {
if (e is FittorException) rethrow;
throw FittorException('Invalid URL format: $e', e);
}
}