Fix: prevent malformed URL error when parsing IP:PORT by adding default scheme if missing

This commit is contained in:
Ruchi Sharma
2025-05-20 13:31:12 +05:30
parent 792e458d40
commit 399f525705

View File

@@ -32,7 +32,13 @@ String stripUrlParams(String url) {
if (kLocalhostRegex.hasMatch(url)) {
url = '${SupportedUriSchemes.http.name}://$url';
} else {
final hasScheme = RegExp(r'^[a-zA-Z][a-zA-Z0-9+.-]*://').hasMatch(url);
if (!hasScheme) {
url = "${defaultUriScheme.name}://$url";
}
}
Uri? uri = Uri.tryParse(url);
if (uri == null) {
return (null, "Check URL (malformed)");