mirror of
https://github.com/foss42/apidash.git
synced 2025-12-14 01:07:53 +08:00
Merge branch 'main' into add-feature-scripts
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,
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:apidash_core/consts.dart';
|
||||
import 'package:seed/seed.dart';
|
||||
import '../models/models.dart';
|
||||
import 'graphql_utils.dart';
|
||||
import 'package:json5/json5.dart' as json5;
|
||||
|
||||
Map<String, String>? rowsToMap(
|
||||
List<NameValueModel>? kvRows, {
|
||||
@@ -100,3 +101,14 @@ String? getRequestBody(APIType type, HttpRequestModel httpRequestModel) {
|
||||
APIType.graphql => getGraphQLBody(httpRequestModel),
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Expose this function to remove JSON comments
|
||||
String? removeJsonComments(String? json) {
|
||||
try {
|
||||
if (json == null) return null;
|
||||
var parsed = json5.json5Decode(json);
|
||||
return kJsonEncoder.convert(parsed);
|
||||
} catch (e) {
|
||||
return json;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,10 @@ 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';
|
||||
}
|
||||
|
||||
Uri? uri = Uri.tryParse(url);
|
||||
if (uri == null) {
|
||||
return (null, "Check URL (malformed)");
|
||||
|
||||
Reference in New Issue
Block a user