File tree Expand file tree Collapse file tree 5 files changed +60
-3
lines changed Expand file tree Collapse file tree 5 files changed +60
-3
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.1.3
2
+
3
+ - Bugfix: Header with ` : ` in value gets parsed properly
4
+
1
5
## 0.1.2
2
6
3
7
- Bump dependencies.
Original file line number Diff line number Diff line change @@ -130,10 +130,15 @@ class Curl extends Equatable {
130
130
headers = < String , String > {};
131
131
for (var headerString in headersList) {
132
132
final splittedHeaderString = headerString.split (RegExp (r':\s*' ));
133
- if (splittedHeaderString.length != 2 ) {
133
+ if (splittedHeaderString.length > 2 ) {
134
+ headers.addAll ({
135
+ splittedHeaderString[0 ]: splittedHeaderString.sublist (1 ).join (":" )
136
+ });
137
+ } else if (splittedHeaderString.length < 2 ) {
134
138
throw Exception ('Failed to split the `$headerString ` header' );
139
+ } else {
140
+ headers.addAll ({splittedHeaderString[0 ]: splittedHeaderString[1 ]});
135
141
}
136
- headers.addAll ({splittedHeaderString[0 ]: splittedHeaderString[1 ]});
137
142
}
138
143
}
139
144
}
Original file line number Diff line number Diff line change 1
1
name : curl_parser
2
2
description : Parse cURL command to Dart object and convert Dart object to cURL command.
3
- version : 0.1.2
3
+ version : 0.1.3
4
4
homepage : https://github.com/foss42/apidash/tree/main/packages/curl_parser
5
5
repository : https://github.com/foss42/apidash/tree/main/packages/curl_parser
6
6
issue_tracker : https://github.com/foss42/apidash/issues
Original file line number Diff line number Diff line change @@ -19,6 +19,30 @@ void main() {
19
19
},
20
20
);
21
21
22
+ test (
23
+ 'parse another easy cURL' ,
24
+ () async {
25
+ expect (
26
+ Curl .parse (
27
+ r"""curl --location --request GET 'https://dummyimage.com/150/92c952' \
28
+ --header 'user-agent: Dart/3.8 (dart:io)' \
29
+ --header 'accept-encoding: gzip' \
30
+ --header 'content-length: 0' \
31
+ --header 'host: dummyimage.com'""" ),
32
+ Curl (
33
+ method: 'GET' ,
34
+ uri: Uri .parse ('https://dummyimage.com/150/92c952' ),
35
+ headers: {
36
+ 'user-agent' : 'Dart/3.8 (dart:io)' ,
37
+ 'accept-encoding' : 'gzip' ,
38
+ 'content-length' : '0' ,
39
+ 'host' : 'dummyimage.com'
40
+ },
41
+ location: true ),
42
+ );
43
+ },
44
+ );
45
+
22
46
test ('parse POST request with multipart/form-data' , () {
23
47
const curl = r'''curl -X POST 'https://api.apidash.dev/io/img' \
24
48
-H 'Content-Type: multipart/form-data' \
Original file line number Diff line number Diff line change @@ -32,6 +32,30 @@ void main() {
32
32
);
33
33
}, timeout: defaultTimeout);
34
34
35
+ test ('parse cURL DevTools' , () async {
36
+ expect (
37
+ splitAsCommandLineArgs (
38
+ r"""--request GET 'https://dummyimage.com/150/92c952' \
39
+ --header 'user-agent: Dart/3.8 (dart:io)' \
40
+ --header 'accept-encoding: gzip' \
41
+ --header 'content-length: 0' \
42
+ --header 'host: dummyimage.com'""" ),
43
+ [
44
+ '--request' ,
45
+ 'GET' ,
46
+ 'https://dummyimage.com/150/92c952' ,
47
+ '--header' ,
48
+ 'user-agent: Dart/3.8 (dart:io)' ,
49
+ '--header' ,
50
+ 'accept-encoding: gzip' ,
51
+ '--header' ,
52
+ 'content-length: 0' ,
53
+ '--header' ,
54
+ 'host: dummyimage.com'
55
+ ],
56
+ );
57
+ }, timeout: defaultTimeout);
58
+
35
59
test ('parse cURL with body' , () async {
36
60
expect (
37
61
splitAsCommandLineArgs (r"""--request POST \
You can’t perform that action at this time.
0 commit comments