minor refactor

This commit is contained in:
Ashita Prasad
2024-11-30 08:55:35 +05:30
parent bbe552d437
commit da1d0efc76
2 changed files with 5 additions and 6 deletions

View File

@ -93,10 +93,6 @@ class Curl extends Equatable {
/// print(Curl.parse('1f')); // [Exception] is thrown
/// ```
static Curl parse(String curlString) {
String? clean(String? url) {
return url?.replaceAll('"', '').replaceAll("'", '');
}
final parser = ArgParser(allowTrailingOptions: true);
// TODO: Add more options
@ -172,8 +168,7 @@ class Curl extends Equatable {
}
// Handle URL and query parameters
String? url = clean(result['url']) ??
(result.rest.isNotEmpty ? clean(result.rest.first) : null);
final url = clean(result['url']) ?? clean(result.rest.firstOrNull);
if (url == null) {
throw Exception('URL is null');
}