mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 22:14:28 +01:00
Add helpful print statements and fix isURL validation
This commit is contained in:
@@ -2,11 +2,13 @@ class UriUtility {
|
|||||||
static bool isURL(String url) {
|
static bool isURL(String url) {
|
||||||
// Validate if the URL string is empty, or contains spaces or invalid characters
|
// Validate if the URL string is empty, or contains spaces or invalid characters
|
||||||
if (url.isEmpty || RegExp(r'[\s<>]').hasMatch(url)) {
|
if (url.isEmpty || RegExp(r'[\s<>]').hasMatch(url)) {
|
||||||
|
print('URL is either empty or contains spaces/invalid characters.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for 'mailto:' at the start of the URL
|
// Check for 'mailto:' at the start of the URL
|
||||||
if (url.startsWith('mailto:')) {
|
if (url.startsWith('mailto:')) {
|
||||||
|
print('URL starts with "mailto:".');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,26 +17,31 @@ class UriUtility {
|
|||||||
try {
|
try {
|
||||||
uri = Uri.parse(url);
|
uri = Uri.parse(url);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
print('URL parsing failed: $e');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the URL has a scheme (protocol) and host
|
// Validate the URL has a scheme (protocol) and host
|
||||||
if (uri.scheme.isEmpty || uri.host.isEmpty) {
|
if (uri.scheme.isEmpty || uri.host.isEmpty) {
|
||||||
|
print('URL is missing a scheme (protocol) or host.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the URI has user info, which is not a common case for a valid HTTP/HTTPS URL
|
// Check if the URI has user info, which is not a common case for a valid HTTP/HTTPS URL
|
||||||
if (uri.hasAuthority &&
|
if (uri.hasAuthority &&
|
||||||
(uri.userInfo.isEmpty ||
|
uri.userInfo.contains(':') &&
|
||||||
uri.userInfo.contains(':') && uri.userInfo.split(':').length > 2)) {
|
uri.userInfo.split(':').length > 2) {
|
||||||
|
print('URL contains invalid user info.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the port number if exists
|
// Validate the port number if exists
|
||||||
if (uri.hasPort && (uri.port <= 0 || uri.port > 65535)) {
|
if (uri.hasPort && (uri.port <= 0 || uri.port > 65535)) {
|
||||||
|
print('URL contains an invalid port number.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('URL is valid.');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,6 +266,7 @@ class SkillTreeViewModel extends ChangeNotifier {
|
|||||||
run.runDetails.runId = uuid;
|
run.runDetails.runId = uuid;
|
||||||
|
|
||||||
await leaderboardService.submitReport(run);
|
await leaderboardService.submitReport(run);
|
||||||
|
print('Completed submission to leaderboard!');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the currentBenchmarkRuns list after submitting to the leaderboard
|
// Clear the currentBenchmarkRuns list after submitting to the leaderboard
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ class _LeaderboardSubmissionDialogState
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
|
print('Valid leaderboard submission parameters!');
|
||||||
_saveToSharedPreferences();
|
_saveToSharedPreferences();
|
||||||
widget.onSubmit?.call(_teamNameController.text, _repoUrlController.text,
|
widget.onSubmit?.call(_teamNameController.text, _repoUrlController.text,
|
||||||
_commitShaController.text);
|
_commitShaController.text);
|
||||||
|
|||||||
Reference in New Issue
Block a user