Bug fix curl_parser

This commit is contained in:
Ashita Prasad
2025-05-25 14:10:14 +05:30
parent 792e458d40
commit 948cf90e65
5 changed files with 60 additions and 3 deletions

View File

@@ -130,10 +130,15 @@ class Curl extends Equatable {
headers = <String, String>{};
for (var headerString in headersList) {
final splittedHeaderString = headerString.split(RegExp(r':\s*'));
if (splittedHeaderString.length != 2) {
if (splittedHeaderString.length > 2) {
headers.addAll({
splittedHeaderString[0]: splittedHeaderString.sublist(1).join(":")
});
} else if (splittedHeaderString.length < 2) {
throw Exception('Failed to split the `$headerString` header');
} else {
headers.addAll({splittedHeaderString[0]: splittedHeaderString[1]});
}
headers.addAll({splittedHeaderString[0]: splittedHeaderString[1]});
}
}
}