mirror of
https://github.com/foss42/apidash.git
synced 2025-12-04 20:13:56 +08:00
feat: harden curl_parser, tolerate flags, improve output, and expand tests
- Pre-filter unknown flags before ArgParser; keep positional args. - Tolerate non-request flags: -v/--verbose, --connect-timeout, --retry, --output, --compressed, -i/--include, --globoff. - Auth: support --oauth2-bearer; map to - Authorization only if absent. - Cookies: parse -b/--cookie; accept -c/--cookie-jar (ignored for request). - URL: prefer first http(s) positional when --url missing; quote cleaning. - Data: merge data-urlencode → data-raw → data-binary → data; default POST when body/form present; HEAD remains HEAD. - Forms: parse -F entries; auto-set multipart Content-Type if missing. - Headers: robust -H parsing for multi-colon values. - toCurlString: deterministic order; fix continuation spacing; emit -d right after headers/form; place -k/-L at end. - Utils: normalize backslash-newlines/CRLF; remove stray '+'; shlex split. - Tests: add unknown flags, oauth2-bearer (and non-override), cookie-jar, verbose/timeout/retry/output tolerance, data merging order, HEAD+data, -A user-agent, -b filename. - Docs: add Dartdoc for utils; class docs present.
This commit is contained in:
@@ -88,4 +88,17 @@ void main() {
|
||||
],
|
||||
);
|
||||
}, timeout: defaultTimeout);
|
||||
|
||||
test('split handles CRLF and backslash-newline', () async {
|
||||
final args = splitAsCommandLineArgs(
|
||||
"--request GET \\\r\n --url 'https://api.apidash.dev/echo' \\\n+ \n --header 'A: 1' ");
|
||||
expect(args, [
|
||||
'--request',
|
||||
'GET',
|
||||
'--url',
|
||||
'https://api.apidash.dev/echo',
|
||||
'--header',
|
||||
'A: 1'
|
||||
]);
|
||||
}, timeout: defaultTimeout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user