Skip to content

Commit 399f525

Browse files
committed
Fix: prevent malformed URL error when parsing IP:PORT by adding default scheme if missing
1 parent 792e458 commit 399f525

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/apidash_core/lib/utils/uri_utils.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ String stripUrlParams(String url) {
3232

3333
if (kLocalhostRegex.hasMatch(url)) {
3434
url = '${SupportedUriSchemes.http.name}://$url';
35+
} else {
36+
final hasScheme = RegExp(r'^[a-zA-Z][a-zA-Z0-9+.-]*://').hasMatch(url);
37+
if (!hasScheme) {
38+
url = "${defaultUriScheme.name}://$url";
39+
}
3540
}
41+
3642
Uri? uri = Uri.tryParse(url);
3743
if (uri == null) {
3844
return (null, "Check URL (malformed)");

0 commit comments

Comments
 (0)