feat(uriScheme): Added the support for uriScheme without prefix http/https

This commit is contained in:
aditya.chaudhary1558@gmail.com
2024-11-01 16:21:26 +05:30
parent a3536b021b
commit 053f7b8f17
2 changed files with 22 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import 'package:collection/collection.dart' show mergeMaps;
import 'package:flutter/foundation.dart';
import '../consts.dart';
import '../models/name_value_model.dart';
import 'http_request_utils.dart';
@ -29,6 +30,10 @@ String stripUrlParams(String url) {
if (url == null || url == "") {
return (null, "URL is missing!");
}
final localhostRegex = RegExp(r'^localhost(:\d+)?(/.*)?$');
if (localhostRegex.hasMatch(url)) {
url = 'http://$url';
}
Uri? uri = Uri.tryParse(url);
if (uri == null) {
return (null, "Check URL (malformed)");