mirror of
https://github.com/foss42/apidash.git
synced 2025-06-01 06:42:07 +08:00
Add SupportedUriSchemes support
This commit is contained in:
@ -13,7 +13,7 @@ enum SupportedUriSchemes { https, http }
|
||||
|
||||
final kSupportedUriSchemes =
|
||||
SupportedUriSchemes.values.map((i) => i.name).toList();
|
||||
const kDefaultUriScheme = "https";
|
||||
const kDefaultUriScheme = SupportedUriSchemes.https;
|
||||
final kLocalhostRegex = RegExp(r'^localhost(:\d+)?(/.*)?$');
|
||||
|
||||
const kMethodsWithBody = [
|
||||
|
@ -11,7 +11,7 @@ typedef HttpResponse = http.Response;
|
||||
|
||||
Future<(HttpResponse?, Duration?, String?)> request(
|
||||
HttpRequestModel requestModel, {
|
||||
String defaultUriScheme = kDefaultUriScheme,
|
||||
SupportedUriSchemes defaultUriScheme = kDefaultUriScheme,
|
||||
}) async {
|
||||
(Uri?, String?) uriRec = getValidRequestUri(
|
||||
requestModel.url,
|
||||
|
@ -5,7 +5,7 @@ import 'http_request_utils.dart';
|
||||
|
||||
(String?, bool) getUriScheme(Uri uri) {
|
||||
if (uri.hasScheme) {
|
||||
if (kSupportedUriSchemes.contains(uri.scheme)) {
|
||||
if (kSupportedUriSchemes.contains(uri.scheme.toLowerCase())) {
|
||||
return (uri.scheme, true);
|
||||
}
|
||||
return (uri.scheme, false);
|
||||
@ -24,7 +24,7 @@ String stripUrlParams(String url) {
|
||||
|
||||
(Uri?, String?) getValidRequestUri(
|
||||
String? url, List<NameValueModel>? requestParams,
|
||||
{String defaultUriScheme = kDefaultUriScheme}) {
|
||||
{SupportedUriSchemes defaultUriScheme = kDefaultUriScheme}) {
|
||||
url = url?.trim();
|
||||
if (url == null || url == "") {
|
||||
return (null, "URL is missing!");
|
||||
@ -44,7 +44,7 @@ String stripUrlParams(String url) {
|
||||
return (null, "Unsupported URL Scheme (${urlScheme.$1})");
|
||||
}
|
||||
} else {
|
||||
url = "$defaultUriScheme://$url";
|
||||
url = "${defaultUriScheme.name}://$url";
|
||||
}
|
||||
|
||||
uri = Uri.parse(url);
|
||||
|
Reference in New Issue
Block a user