mirror of
https://github.com/foss42/apidash.git
synced 2025-12-03 11:27:50 +08:00
fixes
This commit is contained in:
@@ -30,6 +30,8 @@ final kSupportedUriSchemes =
|
||||
SupportedUriSchemes.values.map((i) => i.name).toList();
|
||||
const kDefaultUriScheme = SupportedUriSchemes.https;
|
||||
final kLocalhostRegex = RegExp(r'^localhost(:\d+)?(/.*)?$');
|
||||
final kIPHostRegex =
|
||||
RegExp(r'^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}(:\d+)?(/.*)?$');
|
||||
|
||||
const kMethodsWithBody = [
|
||||
HTTPVerb.post,
|
||||
|
||||
@@ -30,13 +30,8 @@ String stripUrlParams(String url) {
|
||||
return (null, "URL is missing!");
|
||||
}
|
||||
|
||||
if (kLocalhostRegex.hasMatch(url)) {
|
||||
if (kLocalhostRegex.hasMatch(url) || kIPHostRegex.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);
|
||||
|
||||
Reference in New Issue
Block a user