0.3.0 • Published 1 year ago

@scrape-do/curl-parser v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

curl-parser

This module parses curl commands into JavaScript objects. That's used in our playground(You may create a free account to try it out).

Installation

npm i -S @scrape-do/curl-parser

Documentation

Usage:

import { parse, stringify } from "@scrape-do/curl-parser";

const command = parse(
  "curl -X POST -H x-foo:bar -X baz:zap https://httpbin.org"
);

console.log("serialized:", stringify(command));

Notes

not all the curl options are supported, we recognize only a small subset of the commands.
You may refer to index.ts to see the currently known curl options by this module. See const curlOptions: CurlOption[]

Implementation details:

--data-urlencode: If this parameter passed multiple times, it just concatenates the arguments with the &.
Consider this example command:

curl -X POST --data-urlencode foo=bar --data-urlencode bar=zap https://example.com

This would produce this body: foo=bar&bar=zap

0.3.0

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago