mirror of
				https://github.com/1disk/edp445.git
				synced 2024-08-14 22:47:02 +00:00 
			
		
		
		
	Changed alot of things.
This commit is contained in:
		
							parent
							
								
									a5a0523e5a
								
							
						
					
					
						commit
						3513d5390c
					
				
					 2016 changed files with 336930 additions and 9 deletions
				
			
		
							
								
								
									
										692
									
								
								node_modules/superagent/HISTORY.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										692
									
								
								node_modules/superagent/HISTORY.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,692 @@ | |||
| # This HISTORY log is deprecated | ||||
| 
 | ||||
| Please see [GitHub releases page](https://github.com/visionmedia/superagent/releases) for the current changelog. | ||||
| 
 | ||||
| # 4.1.0 (2018-12-26) | ||||
| 
 | ||||
|  * `.connect()` IP/DNS override option (Kornel) | ||||
|  * `.trustLocalhost()` option for allowing broken HTTPS on `localhost` | ||||
|  * `.abort()` used with promises rejects the promise. | ||||
| 
 | ||||
| # 4.0.0 (2018-11-17) | ||||
| 
 | ||||
| ## Breaking changes | ||||
| 
 | ||||
| * Node.js v4 has reached it's end of life, so we no longer support it. It's v6+ or later. We recommend Node.js 10. | ||||
| * We now use ES6 in the browser code, too. | ||||
|   * If you're using Browserify or Webpack to package code for Internet Explorer, you will also have to use Babel. | ||||
|   * The pre-built node_modules/superagent.js is still ES5-compatible. | ||||
| * `.end(…)` returns `undefined` instead of the request. If you need the request object after calling `.end()` (and you probably don't), save it in a variable and call `request.end(…)`. Consider not using `.end()` at all, and migrating to promises by calling `.then()` instead. | ||||
| * In Node, responses with unknown MIME type are buffered by default. To get old behavior, if you use custom _unbuffered_ parsers, add `.buffer(false)` to requests or set `superagent.buffer[yourMimeType] = false`. | ||||
| * Invalid uses of `.pipe()` throw. | ||||
| 
 | ||||
| 
 | ||||
| ## Minor changes | ||||
| 
 | ||||
| * Throw if `req.abort().end()` is called | ||||
| * Throw if using unsupported mix of send and field | ||||
| * Reject `.end()` promise on all error events (Kornel Lesiński) | ||||
| * Set `https.servername` from the `Host` header (Kornel Lesiński) | ||||
| * Leave backticks unencoded in query strings where possible (Ethan Resnick) | ||||
| * Update node-mime to 2.x (Alexey Kucherenko) | ||||
| * Allow default buffer settings based on response-type (shrey) | ||||
| * `response.buffered` is more accurate. | ||||
| 
 | ||||
| # 3.8.3 (2018-04-29) | ||||
| 
 | ||||
| * Add flags for 201 & 422 responses (Nikhil Fadnis) | ||||
| * Emit progress event while uploading Node `Buffer` via send method (Sergey Akhalkov) | ||||
| * Fixed setting correct cookies for redirects (Damien Clark) | ||||
| * Replace .catch with ['catch'] for IE9 Support (Miguel Stevens) | ||||
| 
 | ||||
| # 3.8.2 (2017-12-09) | ||||
| 
 | ||||
| * Fixed handling of exceptions thrown from callbacks | ||||
| * Stricter matching of `+json` MIME types. | ||||
| 
 | ||||
| # 3.8.1 (2017-11-08) | ||||
| 
 | ||||
| * Clear authorization header on cross-domain redirect | ||||
| 
 | ||||
| # 3.8.0 | ||||
| 
 | ||||
| * Added support for "globally" defined headers and event handlers via `superagent.agent()`. It now remembers default settings for all its requests. | ||||
| * Added optional callback to `.retry()` (Alexander Murphy) | ||||
| * Unified auth args handling in node/browser (Edmundo Alvarez) | ||||
| * Fixed error handling in zlib pipes (Kornel) | ||||
| * Documented that 3xx status codes are errors (Mickey Reiss) | ||||
| 
 | ||||
| # 3.7.0 (2017-10-17) | ||||
| 
 | ||||
| * Limit maximum response size. Prevents zip bombs (Kornel) | ||||
| * Catch and pass along errors in `.ok()` callback (Jeremy Ruppel) | ||||
| * Fixed parsing of XHR headers without a newline (nsf) | ||||
| 
 | ||||
| # 3.6.2 (2017-10-02) | ||||
| 
 | ||||
| * Upgrade MIME type dependency to a newer, secure version | ||||
| * Recognize PDF MIME as binary | ||||
| * Fix for error in subsequent require() calls (Steven de Salas) | ||||
| 
 | ||||
| # 3.6.0 (2017-08-20) | ||||
| 
 | ||||
| * Support disabling TCP_NODELAY option ([#1240](https://github.com/visionmedia/superagent/issues/1240)) (xiamengyu) | ||||
| * Send payload in query string for GET and HEAD shorthand API (Peter Lyons) | ||||
| * Support passphrase with pfx certificate (Paul Westerdale (ABRS Limited)) | ||||
| * Documentation improvements (Peter Lyons) | ||||
| * Fixed duplicated query string params ([#1200](https://github.com/visionmedia/superagent/issues/1200)) (Kornel) | ||||
| 
 | ||||
| # 3.5.1 (2017-03-18) | ||||
| 
 | ||||
| * Allow crossDomain errors to be retried ([#1194](https://github.com/visionmedia/superagent/issues/1194)) (Michael Olson) | ||||
| * Read responseType property from the correct object (Julien Dupouy) | ||||
| * Check for ownProperty before adding header (Lucas Vieira) | ||||
| 
 | ||||
| # 3.5.0 (2017-02-23) | ||||
| 
 | ||||
| * Add errno to distinguish between request timeout and body download timeout ([#1184](https://github.com/visionmedia/superagent/issues/1184)) (Kornel Lesiński) | ||||
| * Warn about bogus timeout options ([#1185](https://github.com/visionmedia/superagent/issues/1185)) (Kornel Lesiński) | ||||
| 
 | ||||
| # 3.4.4 (2017-02-17) | ||||
| 
 | ||||
| * Treat videos like images (Kornel Lesiński) | ||||
| * Avoid renaming module (Kornel Lesiński) | ||||
| 
 | ||||
| # 3.4.3 (2017-02-14) | ||||
| 
 | ||||
| * Fixed being able to define own parsers when their mime type starts with `text/` (Damien Clark) | ||||
| * `withCredentials(false)` (Andy Woods) | ||||
| * Use `formData.on` instead of `.once` (Kornel Lesiński) | ||||
| * Ignore `attach("file",null)` (Kornel Lesiński) | ||||
| 
 | ||||
| # 3.4.1 (2017-01-29) | ||||
| 
 | ||||
| * Allow `retry()` and `retry(0)` (Alexander Pope) | ||||
| * Allow optional body/data in DELETE requests (Alpha Shuro) | ||||
| * Fixed query string on retried requests (Kornel Lesiński) | ||||
| 
 | ||||
| # 3.4.0 (2017-01-25) | ||||
| 
 | ||||
| * New `.retry(n)` method and `err.retries` (Alexander Pope) | ||||
| * Docs for HTTPS request (Jun Wan Goh) | ||||
| 
 | ||||
| # 3.3.1 (2016-12-17) | ||||
| 
 | ||||
| * Fixed "double callback bug" warning on timeouts of gzipped responses | ||||
| 
 | ||||
| # 3.3.0 (2016-12-14) | ||||
| 
 | ||||
| * Added `.ok(callback)` that allows customizing which responses are errors (Kornel Lesiński) | ||||
| * Added `.responseType()` to Node version (Kornel Lesiński) | ||||
| * Added `.parse()` to browser version (jakepearson) | ||||
| * Fixed parse error when using `responseType('blob')` (Kornel Lesiński) | ||||
| 
 | ||||
| # 3.2.0 (2016-12-11) | ||||
| 
 | ||||
| * Added `.timeout({response:ms})`, which allows limiting maximum response time independently from total download time (Kornel Lesiński) | ||||
| * Added warnings when `.end()` is called more than once (Kornel Lesiński) | ||||
| * Added `response.links` to browser version (Lukas Eipert) | ||||
| * `btoa` is no longer required in IE9 (Kornel Lesiński) | ||||
| * Fixed `.sortQuery()` on URLs without query strings (Kornel Lesiński) | ||||
| * Refactored common response code into `ResponseBase` (Lukas Eipert) | ||||
| 
 | ||||
| # 3.1.0 (2016-11-28) | ||||
| 
 | ||||
| * Added `.sortQuery()` (vicanso) | ||||
| * Added support for arrays and bools in `.field()` (Kornel Lesiński) | ||||
| * Made `superagent.Request` subclassable without need to patch all static methods (Kornel Lesiński) | ||||
| 
 | ||||
| # 3.0.0 (2016-11-19) | ||||
| 
 | ||||
| * Dropped support for Node 0.x. Please upgrade to at least Node 4. | ||||
| * Dropped support for componentjs (Damien Caselli) | ||||
| * Removed deprecated `.part()`/`superagent.Part` APIs. | ||||
| * Removed unreliable `.body` property on internal response object used by unbuffered parsers. | ||||
|   Note: the normal `response.body` is unaffected. | ||||
| * Multiple `.send()` calls mixing `Buffer`/`Blob` and JSON data are not possible and will now throw instead of messing up the data. | ||||
| * Improved `.send()` data object type check (Fernando Mendes) | ||||
| * Added common prototype for Node and browser versions (Andreas Helmberger) | ||||
| * Added `http+unix:` schema to support Unix sockets (Yuki KAN) | ||||
| * Added full `attach` options parameter in the Node version (Lapo Luchini) | ||||
| * Added `pfx` TLS option with new `pfx()` method. (Reid Burke) | ||||
| * Internally changed `.on` to `.once` to prevent possible memory leaks (Matt Blair) | ||||
| * Made all errors reported as an event (Kornel Lesiński) | ||||
| 
 | ||||
| # 2.3.0 (2016-09-20) | ||||
| 
 | ||||
| * Enabled `.field()` to handle objects (Affan Shahid) | ||||
| * Added authentication with client certificates (terusus) | ||||
| * Added `.catch()` for more Promise-like interface (Maxim Samoilov, Kornel Lesiński) | ||||
| * Silenced errors from incomplete gzip streams for compatibility with web browsers (Kornel Lesiński) | ||||
| * Fixed `event.direction` in uploads (Kornel Lesiński) | ||||
| * Fixed returned value of overwritten response object's `on()` method (Juan Dopazo) | ||||
| 
 | ||||
| # 2.2.0 (2016-08-13) | ||||
| 
 | ||||
| * Added `timedout` property to node Request instance (Alexander Pope) | ||||
| * Unified `null` querystring values in node and browser environments. (George Chung) | ||||
| 
 | ||||
| # 2.1.0 (2016-06-14) | ||||
| 
 | ||||
| * Refactored async parsers. Now the `end` callback waits for async parsers to finish (Kornel Lesiński) | ||||
| * Errors thrown in `.end()` callback don't cause the callback to be called twice (Kornel Lesiński) | ||||
| * Added `headers` to `toJSON()` (Tao) | ||||
| 
 | ||||
| # 2.0.0 (2016-05-29) | ||||
| 
 | ||||
| 
 | ||||
| ## Breaking changes | ||||
| 
 | ||||
| Breaking changes are in rarely used functionality, so we hope upgrade will be smooth for most users. | ||||
| 
 | ||||
| * Browser: The `.parse()` method has been renamed to `.serialize()` for consistency with NodeJS version. | ||||
| * Browser: Query string keys without a value used to be parsed as `'undefined'`, now their value is `''` (empty string) (shura, Kornel Lesiński). | ||||
| * NodeJS: The `redirect` event is called after new query string and headers have been set and is allowed to override the request URL (Kornel Lesiński) | ||||
| * `.then()` returns a real `Promise`. Note that use of superagent with promises now requires a global `Promise` object. | ||||
|   If you target Internet Explorer or Node 0.10, you'll need `require('es6-promise').polyfill()` or similar. | ||||
| * Upgraded all dependencies (Peter Lyons) | ||||
| * Renamed properties documented as `@api private` to have `_prefixed` names (Kornel Lesiński) | ||||
| 
 | ||||
| 
 | ||||
| ## Probably not breaking changes: | ||||
| 
 | ||||
| * Extracted common functions to request-base (Peter Lyons) | ||||
| * Fixed race condition in pipe tests (Peter Lyons) | ||||
| * Handle `FormData` error events (scriptype) | ||||
| * Fixed wrong jsdoc of Request#attach (George Chung) | ||||
| * Updated and improved tests (Peter Lyons) | ||||
| * `request.head()` supports `.redirects(5)` call (Kornel Lesiński) | ||||
| * `response` event is also emitted when using `.pipe()` | ||||
| 
 | ||||
| # 1.8.2 (2016-03-20) | ||||
| 
 | ||||
| * Fixed handling of HTTP status 204 with content-encoding: gzip (Andrew Shelton) | ||||
| * Handling of FormData error events (scriptype) | ||||
| * Fixed parsing of `vnd+json` MIME types (Kornel Lesiński) | ||||
| * Aliased browser implementation of `.parse()` as `.serialize()` for forward compatibility | ||||
| 
 | ||||
| # 1.8.1 (2016-03-14) | ||||
| 
 | ||||
| * Fixed form-data incompatibility with IE9 | ||||
| 
 | ||||
| # 1.8.0 (2016-03-09) | ||||
| 
 | ||||
| * Extracted common code into request-base class (Peter Lyons) | ||||
|   * It does not affect the public API, but please let us know if you notice any plugins/subclasses breaking! | ||||
| * Added option `{type:'auto'}` to `auth` method, which enables browser-native auth types (Jungle, Askar Yusupov) | ||||
| * Added `responseType()` to set XHR `responseType` (chris) | ||||
| * Switched to form-data for browserify-compatible `FormData` (Peter Lyons) | ||||
| * Added `statusCode` to error response when JSON response is malformed (mattdell) | ||||
| * Prevented TCP port conflicts in all tests (Peter Lyons) | ||||
| * Updated form-data dependency | ||||
| 
 | ||||
| # 1.7.2 (2016-01-26) | ||||
| 
 | ||||
| * Fix case-sensitivity of header fields introduced by [`a4ddd6a`](https://github.com/visionmedia/superagent/commit/a4ddd6a). (Edward J. Jinotti) | ||||
| * bump extend dependency, as former version did not contain any license information (Lukas Eipert) | ||||
| 
 | ||||
| # 1.7.1 (2016-01-21) | ||||
| 
 | ||||
| * Fixed a conflict with express when using npm 3.x (Glenn) | ||||
| * Fixed redirects after a multipart/form-data POST request (cyclist2) | ||||
| 
 | ||||
| # 1.7.0 (2016-01-18) | ||||
| 
 | ||||
| * When attaching files, read default filename from the `File` object (JD Isaacks) | ||||
| * Add `direction` property to `progress` events (Joseph Dykstra) | ||||
| * Update component-emitter & formidable (Kornel Lesiński) | ||||
| * Don't re-encode query string needlessly (Ruben Verborgh) | ||||
| * ensure querystring is appended when doing `stream.pipe(request)` (Keith Grennan) | ||||
| * change set header function, not call `this.request()` until call `this.end()` (vicanso) | ||||
| * Add no-op `withCredentials` to Node API (markdalgleish) | ||||
| * fix `delete` breaking on ie8 (kenjiokabe) | ||||
| * Don't let request error override responses (Clay Reimann) | ||||
| * Increased number of tests shared between node and client (Kornel Lesiński) | ||||
| 
 | ||||
| # 1.6.0/1.6.1 (2015-12-09) | ||||
| 
 | ||||
| * avoid misleading CORS error message | ||||
| * added 'progress' event on file/form upload in Node (Olivier Lalonde) | ||||
| * return raw response if the response parsing fails (Rei Colina) | ||||
| * parse content-types ending with `+json` as JSON (Eiryyy) | ||||
| * fix to avoid throwing errors on aborted requests (gjurgens) | ||||
| * retain cookies on redirect when hosts match (Tom Conroy) | ||||
| * added Bower manifest (Johnny Freeman) | ||||
| * upgrade to latest cookiejar (Andy Burke) | ||||
| 
 | ||||
| # 1.5.0 (2015-11-30) | ||||
| 
 | ||||
| * encode array values as `key=1&key=2&key=3` etc... (aalpern, Davis Kim) | ||||
| * avoid the error which is omitted from 'socket hang up' | ||||
| * faster JSON parsing, handling of zlib errors (jbellenger) | ||||
| * fix IE11 sends 'undefined' string if data was undefined (Vadim Goncharov) | ||||
| * alias `del()` method as `delete()` (Aaron Krause) | ||||
| * revert Request#parse since it was actually Response#parse | ||||
| 
 | ||||
| # 1.4.0 (2015-09-14) | ||||
| 
 | ||||
| * add Request#parse method to client library | ||||
| * add missing statusCode in client response | ||||
| * don't apply JSON heuristics if a valid parser is found | ||||
| * fix detection of root object for webworkers | ||||
| 
 | ||||
| # 1.3.0 (2015-08-05) | ||||
| 
 | ||||
| * fix incorrect content-length of data set to buffer | ||||
| * serialize request data takes into account charsets | ||||
| * add basic promise support via a `then` function | ||||
| 
 | ||||
| # 1.2.0 (2015-04-13) | ||||
| 
 | ||||
| * add progress events to downlodas | ||||
| * make usable in webworkers | ||||
| * add support for 308 redirects | ||||
| * update node-form-data dependency | ||||
| * update to work in react native | ||||
| * update node-mime dependency | ||||
| 
 | ||||
| # 1.1.0 (2015-03-13) | ||||
| 
 | ||||
| * Fix responseType checks without xhr2 and ie9 tests (rase-) | ||||
| * errors have .status and .response fields if applicable (defunctzombie) | ||||
| * fix end callback called before saving cookies (rase-) | ||||
| 
 | ||||
| # 1.0.0 / 2015-03-08 | ||||
| 
 | ||||
| * All non-200 responses are treated as errors now. (The callback is called with an error when the response has a status < 200 or >= 300 now. In previous versions this would not have raised an error and the client would have to check the `res` object. See [#283](https://github.com/visionmedia/superagent/issues/283). | ||||
| * keep timeouts intact across redirects (hopkinsth) | ||||
| * handle falsy json values (themaarten) | ||||
| * fire response events in browser version (Schoonology) | ||||
| * getXHR exported in client version (KidsKilla) | ||||
| * remove arity check on `.end()` callbacks (defunctzombie) | ||||
| * avoid setting content-type for host objects (rexxars) | ||||
| * don't index array strings in querystring (travisjeffery) | ||||
| * fix pipe() with redirects (cyrilis) | ||||
| * add xhr2 file download (vstirbu) | ||||
| * set default response type to text/plain if not specified (warrenseine) | ||||
| 
 | ||||
| # 0.21.0 / 2014-11-11 | ||||
| 
 | ||||
| * Trim text before parsing json (gjohnson) | ||||
| * Update tests to express 4 (gaastonsr) | ||||
| * Prevent double callback when error is thrown (pgn-vole) | ||||
| * Fix missing clearTimeout (nickdima) | ||||
| * Update debug (TooTallNate) | ||||
| 
 | ||||
| # 0.20.0 / 2014-10-02 | ||||
| 
 | ||||
| * Add toJSON() to request and response instances. (yields) | ||||
| * Prevent HEAD requests from getting parsed. (gjohnson) | ||||
| * Update debug. (TooTallNate) | ||||
| 
 | ||||
| # 0.19.1 / 2014-09-24 | ||||
| 
 | ||||
| * Fix basic auth issue when password is falsey value. (gjohnson) | ||||
| 
 | ||||
| # 0.19.0 / 2014-09-24 | ||||
| 
 | ||||
| * Add unset() to browser. (shesek) | ||||
| * Prefer XHR over ActiveX. (omeid) | ||||
| * Catch parse errors. (jacwright) | ||||
| * Update qs dependency. (wercker) | ||||
| * Add use() to node. (Financial-Times) | ||||
| * Add response text to errors. (yields) | ||||
| * Don't send empty cookie headers. (undoZen) | ||||
| * Don't parse empty response bodies. (DveMac) | ||||
| * Use hostname when setting cookie host. (prasunsultania) | ||||
| 
 | ||||
| # 0.18.2 / 2014-07-12 | ||||
| 
 | ||||
| * Handle parser errors. (kof) | ||||
| * Ensure not to use default parsers when there is a user defined one. (kof) | ||||
| 
 | ||||
| # 0.18.1 / 2014-07-05 | ||||
| 
 | ||||
| * Upgrade cookiejar dependency (juanpin) | ||||
| * Support image mime types (nebulade) | ||||
| * Make .agent chainable (kof) | ||||
| * Upgrade debug (TooTallNate) | ||||
| * Fix docs (aheckmann) | ||||
| 
 | ||||
| # 0.18.0 / 2014-04-29 | ||||
| 
 | ||||
| * Use "form-data" module for the multipart/form-data implementation. (TooTallNate) | ||||
| * Add basic `field()` and `attach()` functions for HTML5 FormData. (TooTallNate) | ||||
| * Deprecate `part()`. (TooTallNate) | ||||
| * Set default user-agent header. (bevacqua) | ||||
| * Add `unset()` method for removing headers. (bevacqua) | ||||
| * Update cookiejar. (missinglink) | ||||
| * Fix response error formatting. (shesek) | ||||
| 
 | ||||
| # 0.17.0 / 2014-03-06 | ||||
| 
 | ||||
| * supply uri malformed error to the callback (yields) | ||||
| * add request event (yields) | ||||
| * allow simple auth (yields) | ||||
| * add request event (yields) | ||||
| * switch to component/reduce (visionmedia) | ||||
| * fix part content-disposition (mscdex) | ||||
| * add browser testing via zuul (defunctzombie) | ||||
| * adds request.use() (johntron) | ||||
| 
 | ||||
| # 0.16.0 / 2014-01-07 | ||||
| 
 | ||||
| * remove support for 0.6 (superjoe30) | ||||
| * fix CORS withCredentials (wejendorp) | ||||
| * add "test" script (superjoe30) | ||||
| * add request .accept() method (nickl-) | ||||
| * add xml to mime types mappings (nickl-) | ||||
| * fix parse body error on HEAD requests (gjohnson) | ||||
| * fix documentation typos (matteofigus) | ||||
| * fix content-type + charset (bengourley) | ||||
| * fix null values on query parameters (cristiandouce) | ||||
| 
 | ||||
| # 0.15.7 / 2013-10-19 | ||||
| 
 | ||||
| * pin should.js to 1.3.0 due to breaking change in 2.0.x | ||||
| * fix browserify regression | ||||
| 
 | ||||
| # 0.15.5 / 2013-10-09 | ||||
| 
 | ||||
| * add browser field to support browserify | ||||
| * fix .field() value number support | ||||
| 
 | ||||
| # 0.15.4 / 2013-07-09 | ||||
| 
 | ||||
| * node: add a Request#agent() function to set the http Agent to use | ||||
| 
 | ||||
| # 0.15.3 / 2013-07-05 | ||||
| 
 | ||||
| * fix .pipe() unzipping on more recent nodes. Closes [#240](https://github.com/visionmedia/superagent/issues/240) | ||||
| * fix passing an empty object to .query() no longer appends "?" | ||||
| * fix formidable error handling | ||||
| * update formidable | ||||
| 
 | ||||
| # 0.15.2 / 2013-07-02 | ||||
| 
 | ||||
| * fix: emit 'end' when piping. | ||||
| 
 | ||||
| # 0.15.1 / 2013-06-26 | ||||
| 
 | ||||
| * add try/catch around parseLinks | ||||
| 
 | ||||
| # 0.15.0 / 2013-06-25 | ||||
| 
 | ||||
| * make `Response#toError()` have a more meaningful `message` | ||||
| 
 | ||||
| # 0.14.9 / 2013-06-15 | ||||
| 
 | ||||
| * add debug()s to the node client | ||||
| * add .abort() method to node client | ||||
| 
 | ||||
| # 0.14.8 / 2013-06-13 | ||||
| 
 | ||||
| * set .agent = false always | ||||
| * remove X-Requested-With. Closes [#189](https://github.com/visionmedia/superagent/issues/189) | ||||
| 
 | ||||
| # 0.14.7 / 2013-06-06 | ||||
| 
 | ||||
| * fix unzip error handling | ||||
| 
 | ||||
| # 0.14.6 / 2013-05-23 | ||||
| 
 | ||||
| * fix HEAD unzip bug | ||||
| 
 | ||||
| # 0.14.5 / 2013-05-23 | ||||
| 
 | ||||
| * add flag to ensure the callback is **never** invoked twice | ||||
| 
 | ||||
| # 0.14.4 / 2013-05-22 | ||||
| 
 | ||||
| * add superagent.js build output | ||||
| * update qs | ||||
| * update emitter-component | ||||
| * revert "add browser field to support browserify" see [GH-221](https://github.com/visionmedia/superagent/issues/221) | ||||
| 
 | ||||
| # 0.14.3 / 2013-05-18 | ||||
| 
 | ||||
| * add browser field to support browserify | ||||
| 
 | ||||
| # 0.14.2/ 2013-05-07 | ||||
| 
 | ||||
| * add host object check to fix serialization of File/Blobs etc as json | ||||
| 
 | ||||
| # 0.14.1 / 2013-04-09 | ||||
| 
 | ||||
| * update qs | ||||
| 
 | ||||
| # 0.14.0 / 2013-04-02 | ||||
| 
 | ||||
| * add client-side basic auth | ||||
| * fix retaining of .set() header field case | ||||
| 
 | ||||
| # 0.13.0 / 2013-03-13 | ||||
| 
 | ||||
| * add progress events to client | ||||
| * add simple example | ||||
| * add res.headers as alias of res.header for browser client | ||||
| * add res.get(field) to node/client | ||||
| 
 | ||||
| # 0.12.4 / 2013-02-11 | ||||
| 
 | ||||
| * fix get content-type even if can't get other headers in firefox. fixes [#181](https://github.com/visionmedia/superagent/issues/181) | ||||
| 
 | ||||
| # 0.12.3 / 2013-02-11 | ||||
| 
 | ||||
| * add quick "progress" event support | ||||
| 
 | ||||
| # 0.12.2 / 2013-02-04 | ||||
| 
 | ||||
| * add test to check if response acts as a readable stream | ||||
| * add ReadableStream in the Response prototype. | ||||
| * add test to assert correct redirection when the host changes in the location header. | ||||
| * add default Accept-Encoding. Closes [#155](https://github.com/visionmedia/superagent/issues/155) | ||||
| * fix req.pipe() return value of original stream for node parity. Closes [#171](https://github.com/visionmedia/superagent/issues/171) | ||||
| * remove the host header when cleaning headers to properly follow the redirection. | ||||
| 
 | ||||
| # 0.12.1 / 2013-01-10 | ||||
| 
 | ||||
| * add x-domain error handling | ||||
| 
 | ||||
| # 0.12.0 / 2013-01-04 | ||||
| 
 | ||||
| * add header persistence on redirects | ||||
| 
 | ||||
| # 0.11.0 / 2013-01-02 | ||||
| 
 | ||||
| * add .error Error object. Closes [#156](https://github.com/visionmedia/superagent/issues/156) | ||||
| * add forcing of res.text removal for FF HEAD responses. Closes [#162](https://github.com/visionmedia/superagent/issues/162) | ||||
| * add reduce component usage. Closes [#90](https://github.com/visionmedia/superagent/issues/90) | ||||
| * move better-assert dep to development deps | ||||
| 
 | ||||
| # 0.10.0 / 2012-11-14 | ||||
| 
 | ||||
| * add req.timeout(ms) support for the client | ||||
| 
 | ||||
| # 0.9.10 / 2012-11-14 | ||||
| 
 | ||||
| * fix client-side .query(str) support | ||||
| 
 | ||||
| # 0.9.9 / 2012-11-14 | ||||
| 
 | ||||
| * add .parse(fn) support | ||||
| * fix socket hangup with dates in querystring. Closes [#146](https://github.com/visionmedia/superagent/issues/146) | ||||
| * fix socket hangup "error" event when a callback of arity 2 is provided | ||||
| 
 | ||||
| # 0.9.8 / 2012-11-03 | ||||
| 
 | ||||
| * add emission of error from `Request#callback()` | ||||
| * add a better fix for nodes weird socket hang up error | ||||
| * add PUT/POST/PATCH data support to client short-hand functions | ||||
| * add .license property to component.json | ||||
| * change client portion to build using component(1) | ||||
| * fix GET body support [guille] | ||||
| 
 | ||||
| # 0.9.7 / 2012-10-19 | ||||
| 
 | ||||
| * fix `.buffer()` `res.text` when no parser matches | ||||
| 
 | ||||
| # 0.9.6 / 2012-10-17 | ||||
| 
 | ||||
| * change: use `this` when `window` is undefined | ||||
| * update to new component spec [juliangruber] | ||||
| * fix emission of "data" events for compressed responses without encoding. Closes [#125](https://github.com/visionmedia/superagent/issues/125) | ||||
| 
 | ||||
| # 0.9.5 / 2012-10-01 | ||||
| 
 | ||||
| * add field name to .attach() | ||||
| * add text "parser" | ||||
| * refactor isObject() | ||||
| * remove wtf isFunction() helper | ||||
| 
 | ||||
| # 0.9.4 / 2012-09-20 | ||||
| 
 | ||||
| * fix `Buffer` responses [TooTallNate] | ||||
| * fix `res.type` when a "type" param is present [TooTallNate] | ||||
| 
 | ||||
| # 0.9.3 / 2012-09-18 | ||||
| 
 | ||||
| * remove **GET** `.send()` == `.query()` special-case (**API** change !!!) | ||||
| 
 | ||||
| # 0.9.2 / 2012-09-17 | ||||
| 
 | ||||
| * add `.aborted` prop | ||||
| * add `.abort()`. Closes [#115](https://github.com/visionmedia/superagent/issues/115) | ||||
| 
 | ||||
| # 0.9.1 / 2012-09-07 | ||||
| 
 | ||||
| * add `.forbidden` response property | ||||
| * add component.json | ||||
| * change emitter-component to 0.0.5 | ||||
| * fix client-side tests | ||||
| 
 | ||||
| # 0.9.0 / 2012-08-28 | ||||
| 
 | ||||
| * add `.timeout(ms)`. Closes [#17](https://github.com/visionmedia/superagent/issues/17) | ||||
| 
 | ||||
| # 0.8.2 / 2012-08-28 | ||||
| 
 | ||||
| * fix pathname relative redirects. Closes [#112](https://github.com/visionmedia/superagent/issues/112) | ||||
| 
 | ||||
| # 0.8.1 / 2012-08-21 | ||||
| 
 | ||||
| * fix redirects when schema is specified | ||||
| 
 | ||||
| # 0.8.0 / 2012-08-19 | ||||
| 
 | ||||
| * add `res.buffered` flag | ||||
| * add buffering of text/\*, json and forms only by default. Closes [#61](https://github.com/visionmedia/superagent/issues/61) | ||||
| * add `.buffer(false)` cancellation | ||||
| * add cookie jar support [hunterloftis] | ||||
| * add agent functionality [hunterloftis] | ||||
| 
 | ||||
| # 0.7.0 / 2012-08-03 | ||||
| 
 | ||||
| * allow `query()` to be called after the internal `req` has been created [tootallnate] | ||||
| 
 | ||||
| # 0.6.0 / 2012-07-17 | ||||
| 
 | ||||
| * add `res.send('foo=bar')` default of "application/x-www-form-urlencoded" | ||||
| 
 | ||||
| # 0.5.1 / 2012-07-16 | ||||
| 
 | ||||
| * add "methods" dep | ||||
| * add `.end()` arity check to node callbacks | ||||
| * fix unzip support due to weird node internals | ||||
| 
 | ||||
| # 0.5.0 / 2012-06-16 | ||||
| 
 | ||||
| * Added "Link" response header field parsing, exposing `res.links` | ||||
| 
 | ||||
| # 0.4.3 / 2012-06-15 | ||||
| 
 | ||||
| * Added 303, 305 and 307 as redirect status codes [slaskis] | ||||
| * Fixed passing an object as the url | ||||
| 
 | ||||
| # 0.4.2 / 2012-06-02 | ||||
| 
 | ||||
| * Added component support | ||||
| * Fixed redirect data | ||||
| 
 | ||||
| # 0.4.1 / 2012-04-13 | ||||
| 
 | ||||
| * Added HTTP PATCH support | ||||
| * Fixed: GET / HEAD when following redirects. Closes [#86](https://github.com/visionmedia/superagent/issues/86) | ||||
| * Fixed Content-Length detection for multibyte chars | ||||
| 
 | ||||
| # 0.4.0 / 2012-03-04 | ||||
| 
 | ||||
| * Added `.head()` method [browser]. Closes [#78](https://github.com/visionmedia/superagent/issues/78) | ||||
| * Added `make test-cov` support | ||||
| * Added multipart request support. Closes [#11](https://github.com/visionmedia/superagent/issues/11) | ||||
| * Added all methods that node supports. Closes [#71](https://github.com/visionmedia/superagent/issues/71) | ||||
| * Added "response" event providing a Response object. Closes [#28](https://github.com/visionmedia/superagent/issues/28) | ||||
| * Added `.query(obj)`. Closes [#59](https://github.com/visionmedia/superagent/issues/59) | ||||
| * Added `res.type` (browser). Closes [#54](https://github.com/visionmedia/superagent/issues/54) | ||||
| * Changed: default `res.body` and `res.files` to {} | ||||
| * Fixed: port existing query-string fix (browser). Closes [#57](https://github.com/visionmedia/superagent/issues/57) | ||||
| 
 | ||||
| # 0.3.0 / 2012-01-24 | ||||
| 
 | ||||
| * Added deflate/gzip support [guillermo] | ||||
| * Added `res.type` (Content-Type void of params) | ||||
| * Added `res.statusCode` to mirror node | ||||
| * Added `res.headers` to mirror node | ||||
| * Changed: parsers take callbacks | ||||
| * Fixed optional schema support. Closes [#49](https://github.com/visionmedia/superagent/issues/49) | ||||
| 
 | ||||
| # 0.2.0 / 2012-01-05 | ||||
| 
 | ||||
| * Added url auth support | ||||
| * Added `.auth(username, password)` | ||||
| * Added basic auth support [node]. Closes [#41](https://github.com/visionmedia/superagent/issues/41) | ||||
| * Added `make test-docs` | ||||
| * Added guillermo's EventEmitter. Closes [#16](https://github.com/visionmedia/superagent/issues/16) | ||||
| * Removed `Request#data()` for SS, renamed to `send()` | ||||
| * Removed `Request#data()` from client, renamed to `send()` | ||||
| * Fixed array support. [browser] | ||||
| * Fixed array support. Closes [#35](https://github.com/visionmedia/superagent/issues/35) [node] | ||||
| * Fixed `EventEmitter#emit()` | ||||
| 
 | ||||
| # 0.1.3 / 2011-10-25 | ||||
| 
 | ||||
| * Added error to callback | ||||
| * Bumped node dep for 0.5.x | ||||
| 
 | ||||
| # 0.1.2 / 2011-09-24 | ||||
| 
 | ||||
| * Added markdown documentation | ||||
| * Added `request(url[, fn])` support to the client | ||||
| * Added `qs` dependency to package.json | ||||
| * Added options for `Request#pipe()` | ||||
| * Added support for `request(url, callback)` | ||||
| * Added `request(url)` as shortcut for `request.get(url)` | ||||
| * Added `Request#pipe(stream)` | ||||
| * Added inherit from `Stream` | ||||
| * Added multipart support | ||||
| * Added ssl support (node) | ||||
| * Removed Content-Length field from client | ||||
| * Fixed buffering, `setEncoding()` to utf8 [reported by stagas] | ||||
| * Fixed "end" event when piping | ||||
| 
 | ||||
| # 0.1.1 / 2011-08-20 | ||||
| 
 | ||||
| * Added `res.redirect` flag (node) | ||||
| * Added redirect support (node) | ||||
| * Added `Request#redirects(n)` (node) | ||||
| * Added `.set(object)` header field support | ||||
| * Fixed `Content-Length` support | ||||
| 
 | ||||
| # 0.1.0 / 2011-08-09 | ||||
| 
 | ||||
| * Added support for multiple calls to `.data()` | ||||
| * Added support for `.get(uri, obj)` | ||||
| * Added GET `.data()` querystring support | ||||
| * Added IE{6,7,8} support [alexyoung] | ||||
| 
 | ||||
| # 0.0.1 / 2011-08-05 | ||||
| 
 | ||||
| * Initial commit | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
							
								
								
									
										22
									
								
								node_modules/superagent/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								node_modules/superagent/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| (The MIT License) | ||||
| 
 | ||||
| Copyright (c) 2014-2016 TJ Holowaychuk <tj@vision-media.ca> | ||||
| 
 | ||||
| Permission is hereby granted, free of charge, to any person obtaining | ||||
| a copy of this software and associated documentation files (the | ||||
| 'Software'), to deal in the Software without restriction, including | ||||
| without limitation the rights to use, copy, modify, merge, publish, | ||||
| distribute, sublicense, and/or sell copies of the Software, and to | ||||
| permit persons to whom the Software is furnished to do so, subject to | ||||
| the following conditions: | ||||
| 
 | ||||
| The above copyright notice and this permission notice shall be | ||||
| included in all copies or substantial portions of the Software. | ||||
| 
 | ||||
| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||||
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||||
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||||
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
							
								
								
									
										274
									
								
								node_modules/superagent/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										274
									
								
								node_modules/superagent/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,274 @@ | |||
| # superagent | ||||
| 
 | ||||
| [](https://travis-ci.org/visionmedia/superagent) | ||||
| [](https://codecov.io/gh/visionmedia/superagent) | ||||
| [](https://github.com/sindresorhus/xo) | ||||
| [](https://github.com/prettier/prettier) | ||||
| [](https://lass.js.org) | ||||
| [](LICENSE) | ||||
| 
 | ||||
| > Small progressive client-side HTTP request library, and Node.js module with the same API, supporting many high-level HTTP client features | ||||
| 
 | ||||
| 
 | ||||
| ## Table of Contents | ||||
| 
 | ||||
| * [Install](#install) | ||||
| * [Usage](#usage) | ||||
|   * [Node](#node) | ||||
|   * [Browser](#browser) | ||||
| * [Supported Platforms](#supported-platforms) | ||||
|   * [Required Browser Features](#required-browser-features) | ||||
| * [Plugins](#plugins) | ||||
| * [Upgrading from previous versions](#upgrading-from-previous-versions) | ||||
| * [Contributors](#contributors) | ||||
| * [License](#license) | ||||
| 
 | ||||
| 
 | ||||
| ## Install | ||||
| 
 | ||||
| [npm][]: | ||||
| 
 | ||||
| ```sh | ||||
| npm install superagent | ||||
| ``` | ||||
| 
 | ||||
| [yarn][]: | ||||
| 
 | ||||
| ```sh | ||||
| yarn add superagent | ||||
| ``` | ||||
| 
 | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ### Node | ||||
| 
 | ||||
| ```js | ||||
| const superagent = require('superagent'); | ||||
| 
 | ||||
| // callback | ||||
| superagent | ||||
|   .post('/api/pet') | ||||
|   .send({ name: 'Manny', species: 'cat' }) // sends a JSON post body | ||||
|   .set('X-API-Key', 'foobar') | ||||
|   .set('accept', 'json') | ||||
|   .end((err, res) => { | ||||
|     // Calling the end function will send the request | ||||
|   }); | ||||
| 
 | ||||
| // promise with then/catch | ||||
| superagent.post('/api/pet').then(console.log).catch(console.error); | ||||
| 
 | ||||
| // promise with async/await | ||||
| (async () => { | ||||
|   try { | ||||
|     const res = await superagent.post('/api/pet'); | ||||
|     console.log(res); | ||||
|   } catch (err) { | ||||
|     console.error(err); | ||||
|   } | ||||
| })(); | ||||
| ``` | ||||
| 
 | ||||
| ### Browser | ||||
| 
 | ||||
| **The browser-ready, minified version of `superagent` is only 6 KB (minified and gzipped)!** | ||||
| 
 | ||||
| Browser-ready versions of this module are available via [jsdelivr][], [unpkg][], and also in the `node_modules/superagent/dist` folder in downloads of the `superagent` package. | ||||
| 
 | ||||
| > Note that we also provide unminified versions with `.js` instead of `.min.js` file extensions. | ||||
| 
 | ||||
| #### VanillaJS | ||||
| 
 | ||||
| This is the solution for you if you're just using `<script>` tags everywhere! | ||||
| 
 | ||||
| ```html | ||||
| <script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Promise,Symbol,Object.setPrototypeOf,Object.getOwnPropertySymbols,Set,Math.trunc,BigInt,Map,Reflect,WeakMap,WeakRef,WeakSet,BigInt,Map,Reflect,WeakMap,WeakRef,WeakSet"></script> | ||||
| <script src="https://cdn.jsdelivr.net/npm/superagent"></script> | ||||
| <!-- if you wish to use unpkg.com instead: --> | ||||
| <!-- <script src="https://unpkg.com/superagent"></script> --> | ||||
| <script type="text/javascript"> | ||||
|   (function() { | ||||
|     // superagent is exposed as `window.superagent` | ||||
|     // if you wish to use "request" instead please | ||||
|     // uncomment the following line of code: | ||||
|     // `window.request = superagent;` | ||||
|     superagent | ||||
|       .post('/api/pet') | ||||
|       .send({ name: 'Manny', species: 'cat' }) // sends a JSON post body | ||||
|       .set('X-API-Key', 'foobar') | ||||
|       .set('accept', 'json') | ||||
|       .end(function (err, res) { | ||||
|         // Calling the end function will send the request | ||||
|       }); | ||||
|   })(); | ||||
| </script> | ||||
| ``` | ||||
| 
 | ||||
| #### Bundler | ||||
| 
 | ||||
| If you are using [browserify][], [webpack][], [rollup][], or another bundler, then you can follow the same usage as [Node](#node) above. | ||||
| 
 | ||||
| 
 | ||||
| ## Supported Platforms | ||||
| 
 | ||||
| * Node: v6.x+ | ||||
| * Browsers (see [.browserslistrc](.browserslistrc)): | ||||
| 
 | ||||
|   ```sh | ||||
|   npx browserslist | ||||
|   ``` | ||||
| 
 | ||||
|   ```sh | ||||
|   and_chr 71 | ||||
|   and_ff 64 | ||||
|   and_qq 1.2 | ||||
|   and_uc 11.8 | ||||
|   android 67 | ||||
|   android 4.4.3-4.4.4 | ||||
|   baidu 7.12 | ||||
|   bb 10 | ||||
|   bb 7 | ||||
|   chrome 73 | ||||
|   chrome 72 | ||||
|   chrome 71 | ||||
|   edge 18 | ||||
|   edge 17 | ||||
|   firefox 66 | ||||
|   firefox 65 | ||||
|   ie 11 | ||||
|   ie 10 | ||||
|   ie 9 | ||||
|   ie_mob 11 | ||||
|   ie_mob 10 | ||||
|   ios_saf 12.0-12.1 | ||||
|   ios_saf 11.3-11.4 | ||||
|   op_mini all | ||||
|   op_mob 46 | ||||
|   op_mob 12.1 | ||||
|   opera 58 | ||||
|   opera 57 | ||||
|   safari 12 | ||||
|   safari 11.1 | ||||
|   samsung 8.2 | ||||
|   samsung 7.2-7.4 | ||||
|   ``` | ||||
| 
 | ||||
| ### Required Browser Features | ||||
| 
 | ||||
| We recommend using <https://polyfill.io> (specifically with the bundle mentioned in [VanillaJS](#vanillajs) above): | ||||
| 
 | ||||
| ```html | ||||
| <script src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Promise,Symbol,Object.setPrototypeOf,Object.getOwnPropertySymbols,Set,Math.trunc,BigInt,Map,Reflect,WeakMap,WeakRef,WeakSet"></script> | ||||
| ``` | ||||
| 
 | ||||
| * IE 9-10 requires a polyfill for `Promise`, `Array.from`, `Symbol`, `Object.getOwnPropertySymbols`, and `Object.setPrototypeOf` | ||||
| * IE 9 requires a polyfill for `window.FormData` (we recommend [formdata-polyfill][]), `Set`, `Math.trunc`, `BigInt`, `Map`, `Reflect`, `WeakMap`, `WeakRef`, and `WeakSet` | ||||
| 
 | ||||
| 
 | ||||
| ## Plugins | ||||
| 
 | ||||
| SuperAgent is easily extended via plugins. | ||||
| 
 | ||||
| ```js | ||||
| const nocache = require('superagent-no-cache'); | ||||
| const superagent = require('superagent'); | ||||
| const prefix = require('superagent-prefix')('/static'); | ||||
| 
 | ||||
| superagent | ||||
|   .get('/some-url') | ||||
|   .query({ action: 'edit', city: 'London' }) // query string | ||||
|   .use(prefix) // Prefixes *only* this request | ||||
|   .use(nocache) // Prevents caching of *only* this request | ||||
|   .end((err, res) => { | ||||
|     // Do something | ||||
|   }); | ||||
| ``` | ||||
| 
 | ||||
| Existing plugins: | ||||
| 
 | ||||
| * [superagent-no-cache](https://github.com/johntron/superagent-no-cache) - prevents caching by including Cache-Control header | ||||
| * [superagent-prefix](https://github.com/johntron/superagent-prefix) - prefixes absolute URLs (useful in test environment) | ||||
| * [superagent-suffix](https://github.com/timneutkens1/superagent-suffix) - suffix URLs with a given path | ||||
| * [superagent-mock](https://github.com/M6Web/superagent-mock) - simulate HTTP calls by returning data fixtures based on the requested URL | ||||
| * [superagent-mocker](https://github.com/shuvalov-anton/superagent-mocker) — simulate REST API | ||||
| * [superagent-cache](https://github.com/jpodwys/superagent-cache) - A global SuperAgent patch with built-in, flexible caching | ||||
| * [superagent-cache-plugin](https://github.com/jpodwys/superagent-cache-plugin) - A SuperAgent plugin with built-in, flexible caching | ||||
| * [superagent-jsonapify](https://github.com/alex94puchades/superagent-jsonapify) - A lightweight [json-api](http://jsonapi.org/format/) client addon for superagent | ||||
| * [superagent-serializer](https://github.com/zzarcon/superagent-serializer) - Converts server payload into different cases | ||||
| * [superagent-httpbackend](https://www.npmjs.com/package/superagent-httpbackend) - stub out requests using AngularJS' $httpBackend syntax | ||||
| * [superagent-throttle](https://github.com/leviwheatcroft/superagent-throttle) - queues and intelligently throttles requests | ||||
| * [superagent-charset](https://github.com/magicdawn/superagent-charset) - add charset support for node's SuperAgent | ||||
| * [superagent-verbose-errors](https://github.com/jcoreio/superagent-verbose-errors) - include response body in error messages for failed requests | ||||
| * [superagent-declare](https://github.com/damoclark/superagent-declare) - A simple [declarative](https://en.wikipedia.org/wiki/Declarative_programming) API for SuperAgent | ||||
| * [superagent-node-http-timings](https://github.com/webuniverseio/superagent-node-http-timings) - measure http timings in node.js | ||||
| 
 | ||||
| Please prefix your plugin with `superagent-*` so that it can easily be found by others. | ||||
| 
 | ||||
| For SuperAgent extensions such as couchdb and oauth visit the [wiki](https://github.com/visionmedia/superagent/wiki). | ||||
| 
 | ||||
| 
 | ||||
| ## Upgrading from previous versions | ||||
| 
 | ||||
| Please see [GitHub releases page](https://github.com/visionmedia/superagent/releases) for the current changelog. | ||||
| 
 | ||||
| Our breaking changes are mostly in rarely used functionality and from stricter error handling. | ||||
| 
 | ||||
| * [6.0 to 6.1](https://github.com/visionmedia/superagent/releases/tag/v6.1.0) | ||||
|   * Browser behaviour changed to match Node when serializing `application/x-www-form-urlencoded`, using `arrayFormat: 'indices'` semantics of `qs` library. (See: <https://www.npmjs.com/package/qs#stringifying>) | ||||
| * [5.x to 6.x](https://github.com/visionmedia/superagent/releases/tag/v6.0.0): | ||||
|   * Retry behavior is still opt-in, however we now have a more fine-grained list of status codes and error codes that we retry against (see updated docs) | ||||
|   * A specific issue with Content-Type matching not being case-insensitive is fixed | ||||
|   * Set is now required for IE 9, see [Required Browser Features](#required-browser-features) for more insight | ||||
| * [4.x to 5.x](https://github.com/visionmedia/superagent/releases/tag/v5.0.0): | ||||
|   * We've implemented the build setup of [Lass](https://lass.js.org) to simplify our stack and linting | ||||
|   * Unminified browserified build size has been reduced from 48KB to 20KB (via `tinyify` and the latest version of Babel using `@babel/preset-env` and `.browserslistrc`) | ||||
|   * Linting support has been added using `caniuse-lite` and `eslint-plugin-compat` | ||||
|   * We can now target what versions of Node we wish to support more easily using `.babelrc` | ||||
| * [3.x to 4.x](https://github.com/visionmedia/superagent/releases/tag/v4.0.0-alpha.1): | ||||
|   * Ensure you're running Node 6 or later. We've dropped support for Node 4. | ||||
|   * We've started using ES6 and for compatibility with Internet Explorer you may need to use Babel. | ||||
|   * We suggest migrating from `.end()` callbacks to `.then()` or `await`. | ||||
| * [2.x to 3.x](https://github.com/visionmedia/superagent/releases/tag/v3.0.0): | ||||
|   * Ensure you're running Node 4 or later. We've dropped support for Node 0.x. | ||||
|   * Test code that calls `.send()` multiple times. Invalid calls to `.send()` will now throw instead of sending garbage. | ||||
| * [1.x to 2.x](https://github.com/visionmedia/superagent/releases/tag/v2.0.0): | ||||
|   * If you use `.parse()` in the *browser* version, rename it to `.serialize()`. | ||||
|   * If you rely on `undefined` in query-string values being sent literally as the text "undefined", switch to checking for missing value instead. `?key=undefined` is now `?key` (without a value). | ||||
|   * If you use `.then()` in Internet Explorer, ensure that you have a polyfill that adds a global `Promise` object. | ||||
| * 0.x to 1.x: | ||||
|   * Instead of 1-argument callback `.end(function(res){})` use `.then(res => {})`. | ||||
| 
 | ||||
| 
 | ||||
| ## Contributors | ||||
| 
 | ||||
| | Name                | | ||||
| | ------------------- | | ||||
| | **Kornel Lesiński** | | ||||
| | **Peter Lyons**     | | ||||
| | **Hunter Loftis**   | | ||||
| | **Nick Baugh**      | | ||||
| 
 | ||||
| 
 | ||||
| ## License | ||||
| 
 | ||||
| [MIT](LICENSE) © TJ Holowaychuk | ||||
| 
 | ||||
| 
 | ||||
| ## | ||||
| 
 | ||||
| [npm]: https://www.npmjs.com/ | ||||
| 
 | ||||
| [yarn]: https://yarnpkg.com/ | ||||
| 
 | ||||
| [formdata-polyfill]: https://www.npmjs.com/package/formdata-polyfill | ||||
| 
 | ||||
| [jsdelivr]: https://www.jsdelivr.com/ | ||||
| 
 | ||||
| [unpkg]: https://unpkg.com/ | ||||
| 
 | ||||
| [browserify]: https://github.com/browserify/browserify | ||||
| 
 | ||||
| [webpack]: https://github.com/webpack/webpack | ||||
| 
 | ||||
| [rollup]: https://github.com/rollup/rollup | ||||
							
								
								
									
										3975
									
								
								node_modules/superagent/dist/superagent.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3975
									
								
								node_modules/superagent/dist/superagent.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										1
									
								
								node_modules/superagent/dist/superagent.min.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								node_modules/superagent/dist/superagent.min.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										60
									
								
								node_modules/superagent/lib/agent-base.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										60
									
								
								node_modules/superagent/lib/agent-base.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,60 @@ | |||
| "use strict"; | ||||
| 
 | ||||
| function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||||
| 
 | ||||
| function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||||
| 
 | ||||
| function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||||
| 
 | ||||
| function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||||
| 
 | ||||
| function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||||
| 
 | ||||
| function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||||
| 
 | ||||
| function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||||
| 
 | ||||
| function Agent() { | ||||
|   this._defaults = []; | ||||
| } | ||||
| 
 | ||||
| var _loop = function _loop() { | ||||
|   var fn = _arr[_i]; | ||||
| 
 | ||||
|   // Default setting for all requests from this agent
 | ||||
|   Agent.prototype[fn] = function () { | ||||
|     for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||||
|       args[_key] = arguments[_key]; | ||||
|     } | ||||
| 
 | ||||
|     this._defaults.push({ | ||||
|       fn: fn, | ||||
|       args: args | ||||
|     }); | ||||
| 
 | ||||
|     return this; | ||||
|   }; | ||||
| }; | ||||
| 
 | ||||
| for (var _i = 0, _arr = ['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert', 'disableTLSCerts']; _i < _arr.length; _i++) { | ||||
|   _loop(); | ||||
| } | ||||
| 
 | ||||
| Agent.prototype._setDefaults = function (request) { | ||||
|   var _iterator = _createForOfIteratorHelper(this._defaults), | ||||
|       _step; | ||||
| 
 | ||||
|   try { | ||||
|     for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||||
|       var def = _step.value; | ||||
|       request[def.fn].apply(request, _toConsumableArray(def.args)); | ||||
|     } | ||||
|   } catch (err) { | ||||
|     _iterator.e(err); | ||||
|   } finally { | ||||
|     _iterator.f(); | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| module.exports = Agent; | ||||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJBZ2VudCIsIl9kZWZhdWx0cyIsImZuIiwicHJvdG90eXBlIiwiYXJncyIsInB1c2giLCJfc2V0RGVmYXVsdHMiLCJyZXF1ZXN0IiwiZGVmIiwibW9kdWxlIiwiZXhwb3J0cyJdLCJzb3VyY2VzIjpbIi4uL3NyYy9hZ2VudC1iYXNlLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImZ1bmN0aW9uIEFnZW50KCkge1xuICB0aGlzLl9kZWZhdWx0cyA9IFtdO1xufVxuXG5mb3IgKGNvbnN0IGZuIG9mIFtcbiAgJ3VzZScsXG4gICdvbicsXG4gICdvbmNlJyxcbiAgJ3NldCcsXG4gICdxdWVyeScsXG4gICd0eXBlJyxcbiAgJ2FjY2VwdCcsXG4gICdhdXRoJyxcbiAgJ3dpdGhDcmVkZW50aWFscycsXG4gICdzb3J0UXVlcnknLFxuICAncmV0cnknLFxuICAnb2snLFxuICAncmVkaXJlY3RzJyxcbiAgJ3RpbWVvdXQnLFxuICAnYnVmZmVyJyxcbiAgJ3NlcmlhbGl6ZScsXG4gICdwYXJzZScsXG4gICdjYScsXG4gICdrZXknLFxuICAncGZ4JyxcbiAgJ2NlcnQnLFxuICAnZGlzYWJsZVRMU0NlcnRzJ1xuXSkge1xuICAvLyBEZWZhdWx0IHNldHRpbmcgZm9yIGFsbCByZXF1ZXN0cyBmcm9tIHRoaXMgYWdlbnRcbiAgQWdlbnQucHJvdG90eXBlW2ZuXSA9IGZ1bmN0aW9uICguLi5hcmdzKSB7XG4gICAgdGhpcy5fZGVmYXVsdHMucHVzaCh7IGZuLCBhcmdzIH0pO1xuICAgIHJldHVybiB0aGlzO1xuICB9O1xufVxuXG5BZ2VudC5wcm90b3R5cGUuX3NldERlZmF1bHRzID0gZnVuY3Rpb24gKHJlcXVlc3QpIHtcbiAgZm9yIChjb25zdCBkZWYgb2YgdGhpcy5fZGVmYXVsdHMpIHtcbiAgICByZXF1ZXN0W2RlZi5mbl0oLi4uZGVmLmFyZ3MpO1xuICB9XG59O1xuXG5tb2R1bGUuZXhwb3J0cyA9IEFnZW50O1xuIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsU0FBU0EsS0FBVCxHQUFpQjtFQUNmLEtBQUtDLFNBQUwsR0FBaUIsRUFBakI7QUFDRDs7O0VBRUksSUFBTUMsRUFBRSxXQUFSOztFQXdCSDtFQUNBRixLQUFLLENBQUNHLFNBQU4sQ0FBZ0JELEVBQWhCLElBQXNCLFlBQW1CO0lBQUEsa0NBQU5FLElBQU07TUFBTkEsSUFBTTtJQUFBOztJQUN2QyxLQUFLSCxTQUFMLENBQWVJLElBQWYsQ0FBb0I7TUFBRUgsRUFBRSxFQUFGQSxFQUFGO01BQU1FLElBQUksRUFBSkE7SUFBTixDQUFwQjs7SUFDQSxPQUFPLElBQVA7RUFDRCxDQUhEOzs7QUF6QkYsd0JBQWlCLENBQ2YsS0FEZSxFQUVmLElBRmUsRUFHZixNQUhlLEVBSWYsS0FKZSxFQUtmLE9BTGUsRUFNZixNQU5lLEVBT2YsUUFQZSxFQVFmLE1BUmUsRUFTZixpQkFUZSxFQVVmLFdBVmUsRUFXZixPQVhlLEVBWWYsSUFaZSxFQWFmLFdBYmUsRUFjZixTQWRlLEVBZWYsUUFmZSxFQWdCZixXQWhCZSxFQWlCZixPQWpCZSxFQWtCZixJQWxCZSxFQW1CZixLQW5CZSxFQW9CZixLQXBCZSxFQXFCZixNQXJCZSxFQXNCZixpQkF0QmUsQ0FBakIsMEJBdUJHO0VBQUE7QUFNRjs7QUFFREosS0FBSyxDQUFDRyxTQUFOLENBQWdCRyxZQUFoQixHQUErQixVQUFVQyxPQUFWLEVBQW1CO0VBQUEsMkNBQzlCLEtBQUtOLFNBRHlCO0VBQUE7O0VBQUE7SUFDaEQsb0RBQWtDO01BQUEsSUFBdkJPLEdBQXVCO01BQ2hDRCxPQUFPLENBQUNDLEdBQUcsQ0FBQ04sRUFBTCxDQUFQLE9BQUFLLE9BQU8scUJBQVlDLEdBQUcsQ0FBQ0osSUFBaEIsRUFBUDtJQUNEO0VBSCtDO0lBQUE7RUFBQTtJQUFBO0VBQUE7QUFJakQsQ0FKRDs7QUFNQUssTUFBTSxDQUFDQyxPQUFQLEdBQWlCVixLQUFqQiJ9
 | ||||
							
								
								
									
										1052
									
								
								node_modules/superagent/lib/client.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1052
									
								
								node_modules/superagent/lib/client.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										134
									
								
								node_modules/superagent/lib/node/agent.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								node_modules/superagent/lib/node/agent.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										220
									
								
								node_modules/superagent/lib/node/http2wrapper.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										220
									
								
								node_modules/superagent/lib/node/http2wrapper.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										1433
									
								
								node_modules/superagent/lib/node/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1433
									
								
								node_modules/superagent/lib/node/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										13
									
								
								node_modules/superagent/lib/node/parsers/image.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								node_modules/superagent/lib/node/parsers/image.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| "use strict"; | ||||
| 
 | ||||
| module.exports = function (res, fn) { | ||||
|   var data = []; // Binary data needs binary storage
 | ||||
| 
 | ||||
|   res.on('data', function (chunk) { | ||||
|     data.push(chunk); | ||||
|   }); | ||||
|   res.on('end', function () { | ||||
|     fn(null, Buffer.concat(data)); | ||||
|   }); | ||||
| }; | ||||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwicmVzIiwiZm4iLCJkYXRhIiwib24iLCJjaHVuayIsInB1c2giLCJCdWZmZXIiLCJjb25jYXQiXSwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbm9kZS9wYXJzZXJzL2ltYWdlLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gKHJlcywgZm4pID0+IHtcbiAgY29uc3QgZGF0YSA9IFtdOyAvLyBCaW5hcnkgZGF0YSBuZWVkcyBiaW5hcnkgc3RvcmFnZVxuXG4gIHJlcy5vbignZGF0YScsIChjaHVuaykgPT4ge1xuICAgIGRhdGEucHVzaChjaHVuayk7XG4gIH0pO1xuICByZXMub24oJ2VuZCcsICgpID0+IHtcbiAgICBmbihudWxsLCBCdWZmZXIuY29uY2F0KGRhdGEpKTtcbiAgfSk7XG59O1xuIl0sIm1hcHBpbmdzIjoiOztBQUFBQSxNQUFNLENBQUNDLE9BQVAsR0FBaUIsVUFBQ0MsR0FBRCxFQUFNQyxFQUFOLEVBQWE7RUFDNUIsSUFBTUMsSUFBSSxHQUFHLEVBQWIsQ0FENEIsQ0FDWDs7RUFFakJGLEdBQUcsQ0FBQ0csRUFBSixDQUFPLE1BQVAsRUFBZSxVQUFDQyxLQUFELEVBQVc7SUFDeEJGLElBQUksQ0FBQ0csSUFBTCxDQUFVRCxLQUFWO0VBQ0QsQ0FGRDtFQUdBSixHQUFHLENBQUNHLEVBQUosQ0FBTyxLQUFQLEVBQWMsWUFBTTtJQUNsQkYsRUFBRSxDQUFDLElBQUQsRUFBT0ssTUFBTSxDQUFDQyxNQUFQLENBQWNMLElBQWQsQ0FBUCxDQUFGO0VBQ0QsQ0FGRDtBQUdELENBVEQifQ==
 | ||||
							
								
								
									
										12
									
								
								node_modules/superagent/lib/node/parsers/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								node_modules/superagent/lib/node/parsers/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | |||
| "use strict"; | ||||
| 
 | ||||
| exports['application/x-www-form-urlencoded'] = require('./urlencoded'); | ||||
| exports['application/json'] = require('./json'); | ||||
| exports.text = require('./text'); | ||||
| 
 | ||||
| var binary = require('./image'); | ||||
| 
 | ||||
| exports['application/octet-stream'] = binary; | ||||
| exports['application/pdf'] = binary; | ||||
| exports.image = binary; | ||||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJleHBvcnRzIiwicmVxdWlyZSIsInRleHQiLCJiaW5hcnkiLCJpbWFnZSJdLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9ub2RlL3BhcnNlcnMvaW5kZXguanMiXSwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0c1snYXBwbGljYXRpb24veC13d3ctZm9ybS11cmxlbmNvZGVkJ10gPSByZXF1aXJlKCcuL3VybGVuY29kZWQnKTtcbmV4cG9ydHNbJ2FwcGxpY2F0aW9uL2pzb24nXSA9IHJlcXVpcmUoJy4vanNvbicpO1xuZXhwb3J0cy50ZXh0ID0gcmVxdWlyZSgnLi90ZXh0Jyk7XG5cbmNvbnN0IGJpbmFyeSA9IHJlcXVpcmUoJy4vaW1hZ2UnKTtcblxuZXhwb3J0c1snYXBwbGljYXRpb24vb2N0ZXQtc3RyZWFtJ10gPSBiaW5hcnk7XG5leHBvcnRzWydhcHBsaWNhdGlvbi9wZGYnXSA9IGJpbmFyeTtcbmV4cG9ydHMuaW1hZ2UgPSBiaW5hcnk7XG4iXSwibWFwcGluZ3MiOiI7O0FBQUFBLE9BQU8sQ0FBQyxtQ0FBRCxDQUFQLEdBQStDQyxPQUFPLENBQUMsY0FBRCxDQUF0RDtBQUNBRCxPQUFPLENBQUMsa0JBQUQsQ0FBUCxHQUE4QkMsT0FBTyxDQUFDLFFBQUQsQ0FBckM7QUFDQUQsT0FBTyxDQUFDRSxJQUFSLEdBQWVELE9BQU8sQ0FBQyxRQUFELENBQXRCOztBQUVBLElBQU1FLE1BQU0sR0FBR0YsT0FBTyxDQUFDLFNBQUQsQ0FBdEI7O0FBRUFELE9BQU8sQ0FBQywwQkFBRCxDQUFQLEdBQXNDRyxNQUF0QztBQUNBSCxPQUFPLENBQUMsaUJBQUQsQ0FBUCxHQUE2QkcsTUFBN0I7QUFDQUgsT0FBTyxDQUFDSSxLQUFSLEdBQWdCRCxNQUFoQiJ9
 | ||||
							
								
								
									
										26
									
								
								node_modules/superagent/lib/node/parsers/json.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								node_modules/superagent/lib/node/parsers/json.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,26 @@ | |||
| "use strict"; | ||||
| 
 | ||||
| module.exports = function (res, fn) { | ||||
|   res.text = ''; | ||||
|   res.setEncoding('utf8'); | ||||
|   res.on('data', function (chunk) { | ||||
|     res.text += chunk; | ||||
|   }); | ||||
|   res.on('end', function () { | ||||
|     var body; | ||||
|     var error; | ||||
| 
 | ||||
|     try { | ||||
|       body = res.text && JSON.parse(res.text); | ||||
|     } catch (err) { | ||||
|       error = err; // issue #675: return the raw response if the response parsing fails
 | ||||
| 
 | ||||
|       error.rawResponse = res.text || null; // issue #876: return the http status code if the response parsing fails
 | ||||
| 
 | ||||
|       error.statusCode = res.statusCode; | ||||
|     } finally { | ||||
|       fn(error, body); | ||||
|     } | ||||
|   }); | ||||
| }; | ||||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwicmVzIiwiZm4iLCJ0ZXh0Iiwic2V0RW5jb2RpbmciLCJvbiIsImNodW5rIiwiYm9keSIsImVycm9yIiwiSlNPTiIsInBhcnNlIiwiZXJyIiwicmF3UmVzcG9uc2UiLCJzdGF0dXNDb2RlIl0sInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL25vZGUvcGFyc2Vycy9qc29uLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gKHJlcywgZm4pIHtcbiAgcmVzLnRleHQgPSAnJztcbiAgcmVzLnNldEVuY29kaW5nKCd1dGY4Jyk7XG4gIHJlcy5vbignZGF0YScsIChjaHVuaykgPT4ge1xuICAgIHJlcy50ZXh0ICs9IGNodW5rO1xuICB9KTtcbiAgcmVzLm9uKCdlbmQnLCAoKSA9PiB7XG4gICAgbGV0IGJvZHk7XG4gICAgbGV0IGVycm9yO1xuICAgIHRyeSB7XG4gICAgICBib2R5ID0gcmVzLnRleHQgJiYgSlNPTi5wYXJzZShyZXMudGV4dCk7XG4gICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICBlcnJvciA9IGVycjtcbiAgICAgIC8vIGlzc3VlICM2NzU6IHJldHVybiB0aGUgcmF3IHJlc3BvbnNlIGlmIHRoZSByZXNwb25zZSBwYXJzaW5nIGZhaWxzXG4gICAgICBlcnJvci5yYXdSZXNwb25zZSA9IHJlcy50ZXh0IHx8IG51bGw7XG4gICAgICAvLyBpc3N1ZSAjODc2OiByZXR1cm4gdGhlIGh0dHAgc3RhdHVzIGNvZGUgaWYgdGhlIHJlc3BvbnNlIHBhcnNpbmcgZmFpbHNcbiAgICAgIGVycm9yLnN0YXR1c0NvZGUgPSByZXMuc3RhdHVzQ29kZTtcbiAgICB9IGZpbmFsbHkge1xuICAgICAgZm4oZXJyb3IsIGJvZHkpO1xuICAgIH1cbiAgfSk7XG59O1xuIl0sIm1hcHBpbmdzIjoiOztBQUFBQSxNQUFNLENBQUNDLE9BQVAsR0FBaUIsVUFBVUMsR0FBVixFQUFlQyxFQUFmLEVBQW1CO0VBQ2xDRCxHQUFHLENBQUNFLElBQUosR0FBVyxFQUFYO0VBQ0FGLEdBQUcsQ0FBQ0csV0FBSixDQUFnQixNQUFoQjtFQUNBSCxHQUFHLENBQUNJLEVBQUosQ0FBTyxNQUFQLEVBQWUsVUFBQ0MsS0FBRCxFQUFXO0lBQ3hCTCxHQUFHLENBQUNFLElBQUosSUFBWUcsS0FBWjtFQUNELENBRkQ7RUFHQUwsR0FBRyxDQUFDSSxFQUFKLENBQU8sS0FBUCxFQUFjLFlBQU07SUFDbEIsSUFBSUUsSUFBSjtJQUNBLElBQUlDLEtBQUo7O0lBQ0EsSUFBSTtNQUNGRCxJQUFJLEdBQUdOLEdBQUcsQ0FBQ0UsSUFBSixJQUFZTSxJQUFJLENBQUNDLEtBQUwsQ0FBV1QsR0FBRyxDQUFDRSxJQUFmLENBQW5CO0lBQ0QsQ0FGRCxDQUVFLE9BQU9RLEdBQVAsRUFBWTtNQUNaSCxLQUFLLEdBQUdHLEdBQVIsQ0FEWSxDQUVaOztNQUNBSCxLQUFLLENBQUNJLFdBQU4sR0FBb0JYLEdBQUcsQ0FBQ0UsSUFBSixJQUFZLElBQWhDLENBSFksQ0FJWjs7TUFDQUssS0FBSyxDQUFDSyxVQUFOLEdBQW1CWixHQUFHLENBQUNZLFVBQXZCO0lBQ0QsQ0FSRCxTQVFVO01BQ1JYLEVBQUUsQ0FBQ00sS0FBRCxFQUFRRCxJQUFSLENBQUY7SUFDRDtFQUNGLENBZEQ7QUFlRCxDQXJCRCJ9
 | ||||
							
								
								
									
										11
									
								
								node_modules/superagent/lib/node/parsers/text.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								node_modules/superagent/lib/node/parsers/text.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| "use strict"; | ||||
| 
 | ||||
| module.exports = function (res, fn) { | ||||
|   res.text = ''; | ||||
|   res.setEncoding('utf8'); | ||||
|   res.on('data', function (chunk) { | ||||
|     res.text += chunk; | ||||
|   }); | ||||
|   res.on('end', fn); | ||||
| }; | ||||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwicmVzIiwiZm4iLCJ0ZXh0Iiwic2V0RW5jb2RpbmciLCJvbiIsImNodW5rIl0sInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL25vZGUvcGFyc2Vycy90ZXh0LmpzIl0sInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gKHJlcywgZm4pID0+IHtcbiAgcmVzLnRleHQgPSAnJztcbiAgcmVzLnNldEVuY29kaW5nKCd1dGY4Jyk7XG4gIHJlcy5vbignZGF0YScsIChjaHVuaykgPT4ge1xuICAgIHJlcy50ZXh0ICs9IGNodW5rO1xuICB9KTtcbiAgcmVzLm9uKCdlbmQnLCBmbik7XG59O1xuIl0sIm1hcHBpbmdzIjoiOztBQUFBQSxNQUFNLENBQUNDLE9BQVAsR0FBaUIsVUFBQ0MsR0FBRCxFQUFNQyxFQUFOLEVBQWE7RUFDNUJELEdBQUcsQ0FBQ0UsSUFBSixHQUFXLEVBQVg7RUFDQUYsR0FBRyxDQUFDRyxXQUFKLENBQWdCLE1BQWhCO0VBQ0FILEdBQUcsQ0FBQ0ksRUFBSixDQUFPLE1BQVAsRUFBZSxVQUFDQyxLQUFELEVBQVc7SUFDeEJMLEdBQUcsQ0FBQ0UsSUFBSixJQUFZRyxLQUFaO0VBQ0QsQ0FGRDtFQUdBTCxHQUFHLENBQUNJLEVBQUosQ0FBTyxLQUFQLEVBQWNILEVBQWQ7QUFDRCxDQVBEIn0=
 | ||||
							
								
								
									
										22
									
								
								node_modules/superagent/lib/node/parsers/urlencoded.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								node_modules/superagent/lib/node/parsers/urlencoded.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,22 @@ | |||
| "use strict"; | ||||
| 
 | ||||
| /** | ||||
|  * Module dependencies. | ||||
|  */ | ||||
| var qs = require('qs'); | ||||
| 
 | ||||
| module.exports = function (res, fn) { | ||||
|   res.text = ''; | ||||
|   res.setEncoding('ascii'); | ||||
|   res.on('data', function (chunk) { | ||||
|     res.text += chunk; | ||||
|   }); | ||||
|   res.on('end', function () { | ||||
|     try { | ||||
|       fn(null, qs.parse(res.text)); | ||||
|     } catch (err) { | ||||
|       fn(err); | ||||
|     } | ||||
|   }); | ||||
| }; | ||||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJxcyIsInJlcXVpcmUiLCJtb2R1bGUiLCJleHBvcnRzIiwicmVzIiwiZm4iLCJ0ZXh0Iiwic2V0RW5jb2RpbmciLCJvbiIsImNodW5rIiwicGFyc2UiLCJlcnIiXSwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvbm9kZS9wYXJzZXJzL3VybGVuY29kZWQuanMiXSwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBNb2R1bGUgZGVwZW5kZW5jaWVzLlxuICovXG5cbmNvbnN0IHFzID0gcmVxdWlyZSgncXMnKTtcblxubW9kdWxlLmV4cG9ydHMgPSAocmVzLCBmbikgPT4ge1xuICByZXMudGV4dCA9ICcnO1xuICByZXMuc2V0RW5jb2RpbmcoJ2FzY2lpJyk7XG4gIHJlcy5vbignZGF0YScsIChjaHVuaykgPT4ge1xuICAgIHJlcy50ZXh0ICs9IGNodW5rO1xuICB9KTtcbiAgcmVzLm9uKCdlbmQnLCAoKSA9PiB7XG4gICAgdHJ5IHtcbiAgICAgIGZuKG51bGwsIHFzLnBhcnNlKHJlcy50ZXh0KSk7XG4gICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICBmbihlcnIpO1xuICAgIH1cbiAgfSk7XG59O1xuIl0sIm1hcHBpbmdzIjoiOztBQUFBO0FBQ0E7QUFDQTtBQUVBLElBQU1BLEVBQUUsR0FBR0MsT0FBTyxDQUFDLElBQUQsQ0FBbEI7O0FBRUFDLE1BQU0sQ0FBQ0MsT0FBUCxHQUFpQixVQUFDQyxHQUFELEVBQU1DLEVBQU4sRUFBYTtFQUM1QkQsR0FBRyxDQUFDRSxJQUFKLEdBQVcsRUFBWDtFQUNBRixHQUFHLENBQUNHLFdBQUosQ0FBZ0IsT0FBaEI7RUFDQUgsR0FBRyxDQUFDSSxFQUFKLENBQU8sTUFBUCxFQUFlLFVBQUNDLEtBQUQsRUFBVztJQUN4QkwsR0FBRyxDQUFDRSxJQUFKLElBQVlHLEtBQVo7RUFDRCxDQUZEO0VBR0FMLEdBQUcsQ0FBQ0ksRUFBSixDQUFPLEtBQVAsRUFBYyxZQUFNO0lBQ2xCLElBQUk7TUFDRkgsRUFBRSxDQUFDLElBQUQsRUFBT0wsRUFBRSxDQUFDVSxLQUFILENBQVNOLEdBQUcsQ0FBQ0UsSUFBYixDQUFQLENBQUY7SUFDRCxDQUZELENBRUUsT0FBT0ssR0FBUCxFQUFZO01BQ1pOLEVBQUUsQ0FBQ00sR0FBRCxDQUFGO0lBQ0Q7RUFDRixDQU5EO0FBT0QsQ0FiRCJ9
 | ||||
							
								
								
									
										137
									
								
								node_modules/superagent/lib/node/response.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								node_modules/superagent/lib/node/response.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										72
									
								
								node_modules/superagent/lib/node/unzip.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										72
									
								
								node_modules/superagent/lib/node/unzip.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,72 @@ | |||
| "use strict"; | ||||
| 
 | ||||
| /** | ||||
|  * Module dependencies. | ||||
|  */ | ||||
| var _require = require('string_decoder'), | ||||
|     StringDecoder = _require.StringDecoder; | ||||
| 
 | ||||
| var Stream = require('stream'); | ||||
| 
 | ||||
| var zlib = require('zlib'); | ||||
| /** | ||||
|  * Buffers response data events and re-emits when they're unzipped. | ||||
|  * | ||||
|  * @param {Request} req | ||||
|  * @param {Response} res | ||||
|  * @api private | ||||
|  */ | ||||
| 
 | ||||
| 
 | ||||
| exports.unzip = function (request, res) { | ||||
|   var unzip = zlib.createUnzip(); | ||||
|   var stream = new Stream(); | ||||
|   var decoder; // make node responseOnEnd() happy
 | ||||
| 
 | ||||
|   stream.req = request; | ||||
|   unzip.on('error', function (error) { | ||||
|     if (error && error.code === 'Z_BUF_ERROR') { | ||||
|       // unexpected end of file is ignored by browsers and curl
 | ||||
|       stream.emit('end'); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     stream.emit('error', error); | ||||
|   }); // pipe to unzip
 | ||||
| 
 | ||||
|   res.pipe(unzip); // override `setEncoding` to capture encoding
 | ||||
| 
 | ||||
|   res.setEncoding = function (type) { | ||||
|     decoder = new StringDecoder(type); | ||||
|   }; // decode upon decompressing with captured encoding
 | ||||
| 
 | ||||
| 
 | ||||
|   unzip.on('data', function (buf) { | ||||
|     if (decoder) { | ||||
|       var string_ = decoder.write(buf); | ||||
|       if (string_.length > 0) stream.emit('data', string_); | ||||
|     } else { | ||||
|       stream.emit('data', buf); | ||||
|     } | ||||
|   }); | ||||
|   unzip.on('end', function () { | ||||
|     stream.emit('end'); | ||||
|   }); // override `on` to capture data listeners
 | ||||
| 
 | ||||
|   var _on = res.on; | ||||
| 
 | ||||
|   res.on = function (type, fn) { | ||||
|     if (type === 'data' || type === 'end') { | ||||
|       stream.on(type, fn.bind(res)); | ||||
|     } else if (type === 'error') { | ||||
|       stream.on(type, fn.bind(res)); | ||||
| 
 | ||||
|       _on.call(res, type, fn); | ||||
|     } else { | ||||
|       _on.call(res, type, fn); | ||||
|     } | ||||
| 
 | ||||
|     return this; | ||||
|   }; | ||||
| }; | ||||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJyZXF1aXJlIiwiU3RyaW5nRGVjb2RlciIsIlN0cmVhbSIsInpsaWIiLCJleHBvcnRzIiwidW56aXAiLCJyZXF1ZXN0IiwicmVzIiwiY3JlYXRlVW56aXAiLCJzdHJlYW0iLCJkZWNvZGVyIiwicmVxIiwib24iLCJlcnJvciIsImNvZGUiLCJlbWl0IiwicGlwZSIsInNldEVuY29kaW5nIiwidHlwZSIsImJ1ZiIsInN0cmluZ18iLCJ3cml0ZSIsImxlbmd0aCIsIl9vbiIsImZuIiwiYmluZCIsImNhbGwiXSwic291cmNlcyI6WyIuLi8uLi9zcmMvbm9kZS91bnppcC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIE1vZHVsZSBkZXBlbmRlbmNpZXMuXG4gKi9cblxuY29uc3QgeyBTdHJpbmdEZWNvZGVyIH0gPSByZXF1aXJlKCdzdHJpbmdfZGVjb2RlcicpO1xuY29uc3QgU3RyZWFtID0gcmVxdWlyZSgnc3RyZWFtJyk7XG5jb25zdCB6bGliID0gcmVxdWlyZSgnemxpYicpO1xuXG4vKipcbiAqIEJ1ZmZlcnMgcmVzcG9uc2UgZGF0YSBldmVudHMgYW5kIHJlLWVtaXRzIHdoZW4gdGhleSdyZSB1bnppcHBlZC5cbiAqXG4gKiBAcGFyYW0ge1JlcXVlc3R9IHJlcVxuICogQHBhcmFtIHtSZXNwb25zZX0gcmVzXG4gKiBAYXBpIHByaXZhdGVcbiAqL1xuXG5leHBvcnRzLnVuemlwID0gKHJlcXVlc3QsIHJlcykgPT4ge1xuICBjb25zdCB1bnppcCA9IHpsaWIuY3JlYXRlVW56aXAoKTtcbiAgY29uc3Qgc3RyZWFtID0gbmV3IFN0cmVhbSgpO1xuICBsZXQgZGVjb2RlcjtcblxuICAvLyBtYWtlIG5vZGUgcmVzcG9uc2VPbkVuZCgpIGhhcHB5XG4gIHN0cmVhbS5yZXEgPSByZXF1ZXN0O1xuXG4gIHVuemlwLm9uKCdlcnJvcicsIChlcnJvcikgPT4ge1xuICAgIGlmIChlcnJvciAmJiBlcnJvci5jb2RlID09PSAnWl9CVUZfRVJST1InKSB7XG4gICAgICAvLyB1bmV4cGVjdGVkIGVuZCBvZiBmaWxlIGlzIGlnbm9yZWQgYnkgYnJvd3NlcnMgYW5kIGN1cmxcbiAgICAgIHN0cmVhbS5lbWl0KCdlbmQnKTtcbiAgICAgIHJldHVybjtcbiAgICB9XG5cbiAgICBzdHJlYW0uZW1pdCgnZXJyb3InLCBlcnJvcik7XG4gIH0pO1xuXG4gIC8vIHBpcGUgdG8gdW56aXBcbiAgcmVzLnBpcGUodW56aXApO1xuXG4gIC8vIG92ZXJyaWRlIGBzZXRFbmNvZGluZ2AgdG8gY2FwdHVyZSBlbmNvZGluZ1xuICByZXMuc2V0RW5jb2RpbmcgPSAodHlwZSkgPT4ge1xuICAgIGRlY29kZXIgPSBuZXcgU3RyaW5nRGVjb2Rlcih0eXBlKTtcbiAgfTtcblxuICAvLyBkZWNvZGUgdXBvbiBkZWNvbXByZXNzaW5nIHdpdGggY2FwdHVyZWQgZW5jb2RpbmdcbiAgdW56aXAub24oJ2RhdGEnLCAoYnVmKSA9PiB7XG4gICAgaWYgKGRlY29kZXIpIHtcbiAgICAgIGNvbnN0IHN0cmluZ18gPSBkZWNvZGVyLndyaXRlKGJ1Zik7XG4gICAgICBpZiAoc3RyaW5nXy5sZW5ndGggPiAwKSBzdHJlYW0uZW1pdCgnZGF0YScsIHN0cmluZ18pO1xuICAgIH0gZWxzZSB7XG4gICAgICBzdHJlYW0uZW1pdCgnZGF0YScsIGJ1Zik7XG4gICAgfVxuICB9KTtcblxuICB1bnppcC5vbignZW5kJywgKCkgPT4ge1xuICAgIHN0cmVhbS5lbWl0KCdlbmQnKTtcbiAgfSk7XG5cbiAgLy8gb3ZlcnJpZGUgYG9uYCB0byBjYXB0dXJlIGRhdGEgbGlzdGVuZXJzXG4gIGNvbnN0IF9vbiA9IHJlcy5vbjtcbiAgcmVzLm9uID0gZnVuY3Rpb24gKHR5cGUsIGZuKSB7XG4gICAgaWYgKHR5cGUgPT09ICdkYXRhJyB8fCB0eXBlID09PSAnZW5kJykge1xuICAgICAgc3RyZWFtLm9uKHR5cGUsIGZuLmJpbmQocmVzKSk7XG4gICAgfSBlbHNlIGlmICh0eXBlID09PSAnZXJyb3InKSB7XG4gICAgICBzdHJlYW0ub24odHlwZSwgZm4uYmluZChyZXMpKTtcbiAgICAgIF9vbi5jYWxsKHJlcywgdHlwZSwgZm4pO1xuICAgIH0gZWxzZSB7XG4gICAgICBfb24uY2FsbChyZXMsIHR5cGUsIGZuKTtcbiAgICB9XG5cbiAgICByZXR1cm4gdGhpcztcbiAgfTtcbn07XG4iXSwibWFwcGluZ3MiOiI7O0FBQUE7QUFDQTtBQUNBO0FBRUEsZUFBMEJBLE9BQU8sQ0FBQyxnQkFBRCxDQUFqQztBQUFBLElBQVFDLGFBQVIsWUFBUUEsYUFBUjs7QUFDQSxJQUFNQyxNQUFNLEdBQUdGLE9BQU8sQ0FBQyxRQUFELENBQXRCOztBQUNBLElBQU1HLElBQUksR0FBR0gsT0FBTyxDQUFDLE1BQUQsQ0FBcEI7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7O0FBRUFJLE9BQU8sQ0FBQ0MsS0FBUixHQUFnQixVQUFDQyxPQUFELEVBQVVDLEdBQVYsRUFBa0I7RUFDaEMsSUFBTUYsS0FBSyxHQUFHRixJQUFJLENBQUNLLFdBQUwsRUFBZDtFQUNBLElBQU1DLE1BQU0sR0FBRyxJQUFJUCxNQUFKLEVBQWY7RUFDQSxJQUFJUSxPQUFKLENBSGdDLENBS2hDOztFQUNBRCxNQUFNLENBQUNFLEdBQVAsR0FBYUwsT0FBYjtFQUVBRCxLQUFLLENBQUNPLEVBQU4sQ0FBUyxPQUFULEVBQWtCLFVBQUNDLEtBQUQsRUFBVztJQUMzQixJQUFJQSxLQUFLLElBQUlBLEtBQUssQ0FBQ0MsSUFBTixLQUFlLGFBQTVCLEVBQTJDO01BQ3pDO01BQ0FMLE1BQU0sQ0FBQ00sSUFBUCxDQUFZLEtBQVo7TUFDQTtJQUNEOztJQUVETixNQUFNLENBQUNNLElBQVAsQ0FBWSxPQUFaLEVBQXFCRixLQUFyQjtFQUNELENBUkQsRUFSZ0MsQ0FrQmhDOztFQUNBTixHQUFHLENBQUNTLElBQUosQ0FBU1gsS0FBVCxFQW5CZ0MsQ0FxQmhDOztFQUNBRSxHQUFHLENBQUNVLFdBQUosR0FBa0IsVUFBQ0MsSUFBRCxFQUFVO0lBQzFCUixPQUFPLEdBQUcsSUFBSVQsYUFBSixDQUFrQmlCLElBQWxCLENBQVY7RUFDRCxDQUZELENBdEJnQyxDQTBCaEM7OztFQUNBYixLQUFLLENBQUNPLEVBQU4sQ0FBUyxNQUFULEVBQWlCLFVBQUNPLEdBQUQsRUFBUztJQUN4QixJQUFJVCxPQUFKLEVBQWE7TUFDWCxJQUFNVSxPQUFPLEdBQUdWLE9BQU8sQ0FBQ1csS0FBUixDQUFjRixHQUFkLENBQWhCO01BQ0EsSUFBSUMsT0FBTyxDQUFDRSxNQUFSLEdBQWlCLENBQXJCLEVBQXdCYixNQUFNLENBQUNNLElBQVAsQ0FBWSxNQUFaLEVBQW9CSyxPQUFwQjtJQUN6QixDQUhELE1BR087TUFDTFgsTUFBTSxDQUFDTSxJQUFQLENBQVksTUFBWixFQUFvQkksR0FBcEI7SUFDRDtFQUNGLENBUEQ7RUFTQWQsS0FBSyxDQUFDTyxFQUFOLENBQVMsS0FBVCxFQUFnQixZQUFNO0lBQ3BCSCxNQUFNLENBQUNNLElBQVAsQ0FBWSxLQUFaO0VBQ0QsQ0FGRCxFQXBDZ0MsQ0F3Q2hDOztFQUNBLElBQU1RLEdBQUcsR0FBR2hCLEdBQUcsQ0FBQ0ssRUFBaEI7O0VBQ0FMLEdBQUcsQ0FBQ0ssRUFBSixHQUFTLFVBQVVNLElBQVYsRUFBZ0JNLEVBQWhCLEVBQW9CO0lBQzNCLElBQUlOLElBQUksS0FBSyxNQUFULElBQW1CQSxJQUFJLEtBQUssS0FBaEMsRUFBdUM7TUFDckNULE1BQU0sQ0FBQ0csRUFBUCxDQUFVTSxJQUFWLEVBQWdCTSxFQUFFLENBQUNDLElBQUgsQ0FBUWxCLEdBQVIsQ0FBaEI7SUFDRCxDQUZELE1BRU8sSUFBSVcsSUFBSSxLQUFLLE9BQWIsRUFBc0I7TUFDM0JULE1BQU0sQ0FBQ0csRUFBUCxDQUFVTSxJQUFWLEVBQWdCTSxFQUFFLENBQUNDLElBQUgsQ0FBUWxCLEdBQVIsQ0FBaEI7O01BQ0FnQixHQUFHLENBQUNHLElBQUosQ0FBU25CLEdBQVQsRUFBY1csSUFBZCxFQUFvQk0sRUFBcEI7SUFDRCxDQUhNLE1BR0E7TUFDTEQsR0FBRyxDQUFDRyxJQUFKLENBQVNuQixHQUFULEVBQWNXLElBQWQsRUFBb0JNLEVBQXBCO0lBQ0Q7O0lBRUQsT0FBTyxJQUFQO0VBQ0QsQ0FYRDtBQVlELENBdEREIn0=
 | ||||
							
								
								
									
										793
									
								
								node_modules/superagent/lib/request-base.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										793
									
								
								node_modules/superagent/lib/request-base.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										113
									
								
								node_modules/superagent/lib/response-base.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								node_modules/superagent/lib/response-base.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										142
									
								
								node_modules/superagent/lib/utils.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								node_modules/superagent/lib/utils.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										19
									
								
								node_modules/superagent/node_modules/form-data/License
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								node_modules/superagent/node_modules/form-data/License
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | |||
| Copyright (c) 2012 Felix Geisendörfer (felix@debuggable.com) and contributors | ||||
| 
 | ||||
|  Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
|  of this software and associated documentation files (the "Software"), to deal | ||||
|  in the Software without restriction, including without limitation the rights | ||||
|  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||||
|  copies of the Software, and to permit persons to whom the Software is | ||||
|  furnished to do so, subject to the following conditions: | ||||
| 
 | ||||
|  The above copyright notice and this permission notice shall be included in | ||||
|  all copies or substantial portions of the Software. | ||||
| 
 | ||||
|  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
|  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
|  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
|  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
|  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||||
|  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||||
|  THE SOFTWARE. | ||||
							
								
								
									
										358
									
								
								node_modules/superagent/node_modules/form-data/README.md.bak
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										358
									
								
								node_modules/superagent/node_modules/form-data/README.md.bak
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,358 @@ | |||
| # Form-Data [](https://www.npmjs.com/package/form-data) [](https://gitter.im/form-data/form-data) | ||||
| 
 | ||||
| A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications. | ||||
| 
 | ||||
| The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd]. | ||||
| 
 | ||||
| [xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface | ||||
| 
 | ||||
| [](https://travis-ci.org/form-data/form-data) | ||||
| [](https://travis-ci.org/form-data/form-data) | ||||
| [](https://travis-ci.org/form-data/form-data) | ||||
| 
 | ||||
| [](https://coveralls.io/github/form-data/form-data?branch=master) | ||||
| [](https://david-dm.org/form-data/form-data) | ||||
| 
 | ||||
| ## Install | ||||
| 
 | ||||
| ``` | ||||
| npm install --save form-data | ||||
| ``` | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| In this example we are constructing a form with 3 fields that contain a string, | ||||
| a buffer and a file stream. | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| var fs = require('fs'); | ||||
| 
 | ||||
| var form = new FormData(); | ||||
| form.append('my_field', 'my value'); | ||||
| form.append('my_buffer', new Buffer(10)); | ||||
| form.append('my_file', fs.createReadStream('/foo/bar.jpg')); | ||||
| ``` | ||||
| 
 | ||||
| Also you can use http-response stream: | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| var http = require('http'); | ||||
| 
 | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| http.request('http://nodejs.org/images/logo.png', function(response) { | ||||
|   form.append('my_field', 'my value'); | ||||
|   form.append('my_buffer', new Buffer(10)); | ||||
|   form.append('my_logo', response); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| Or @mikeal's [request](https://github.com/request/request) stream: | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| var request = require('request'); | ||||
| 
 | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| form.append('my_field', 'my value'); | ||||
| form.append('my_buffer', new Buffer(10)); | ||||
| form.append('my_logo', request('http://nodejs.org/images/logo.png')); | ||||
| ``` | ||||
| 
 | ||||
| In order to submit this form to a web application, call ```submit(url, [callback])``` method: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit('http://example.org/', function(err, res) { | ||||
|   // res – response object (http.IncomingMessage)  // | ||||
|   res.resume(); | ||||
| }); | ||||
| 
 | ||||
| ``` | ||||
| 
 | ||||
| For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods. | ||||
| 
 | ||||
| ### Custom options | ||||
| 
 | ||||
| You can provide custom options, such as `maxDataSize`: | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| 
 | ||||
| var form = new FormData({ maxDataSize: 20971520 }); | ||||
| form.append('my_field', 'my value'); | ||||
| form.append('my_buffer', /* something big */); | ||||
| ``` | ||||
| 
 | ||||
| List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15) | ||||
| 
 | ||||
| ### Alternative submission methods | ||||
| 
 | ||||
| You can use node's http client interface: | ||||
| 
 | ||||
| ``` javascript | ||||
| var http = require('http'); | ||||
| 
 | ||||
| var request = http.request({ | ||||
|   method: 'post', | ||||
|   host: 'example.org', | ||||
|   path: '/upload', | ||||
|   headers: form.getHeaders() | ||||
| }); | ||||
| 
 | ||||
| form.pipe(request); | ||||
| 
 | ||||
| request.on('response', function(res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| Or if you would prefer the `'Content-Length'` header to be set for you: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit('example.org/upload', function(err, res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| To use custom headers and pre-known length in parts: | ||||
| 
 | ||||
| ``` javascript | ||||
| var CRLF = '\r\n'; | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| var options = { | ||||
|   header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF, | ||||
|   knownLength: 1 | ||||
| }; | ||||
| 
 | ||||
| form.append('my_buffer', buffer, options); | ||||
| 
 | ||||
| form.submit('http://example.com/', function(err, res) { | ||||
|   if (err) throw err; | ||||
|   console.log('Done'); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually: | ||||
| 
 | ||||
| ``` javascript | ||||
| someModule.stream(function(err, stdout, stderr) { | ||||
|   if (err) throw err; | ||||
| 
 | ||||
|   var form = new FormData(); | ||||
| 
 | ||||
|   form.append('file', stdout, { | ||||
|     filename: 'unicycle.jpg', // ... or: | ||||
|     filepath: 'photos/toys/unicycle.jpg', | ||||
|     contentType: 'image/jpeg', | ||||
|     knownLength: 19806 | ||||
|   }); | ||||
| 
 | ||||
|   form.submit('http://example.com/', function(err, res) { | ||||
|     if (err) throw err; | ||||
|     console.log('Done'); | ||||
|   }); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory). | ||||
| 
 | ||||
| For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit({ | ||||
|   host: 'example.com', | ||||
|   path: '/probably.php?extra=params', | ||||
|   auth: 'username:password' | ||||
| }, function(err, res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit({ | ||||
|   host: 'example.com', | ||||
|   path: '/surelynot.php', | ||||
|   headers: {'x-test-header': 'test-header-value'} | ||||
| }, function(err, res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| ### Methods | ||||
| 
 | ||||
| - [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-). | ||||
| - [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-) | ||||
| - [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary) | ||||
| - [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary) | ||||
| - [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer) | ||||
| - [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync) | ||||
| - [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-) | ||||
| - [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength) | ||||
| - [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-) | ||||
| - [_String_ toString()](https://github.com/form-data/form-data#string-tostring) | ||||
| 
 | ||||
| #### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] ) | ||||
| Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user. | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| form.append( 'my_string', 'my value' ); | ||||
| form.append( 'my_integer', 1 ); | ||||
| form.append( 'my_boolean', true ); | ||||
| form.append( 'my_buffer', new Buffer(10) ); | ||||
| form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) ) | ||||
| ``` | ||||
| 
 | ||||
| You may provide a string for options, or an object. | ||||
| ```javascript | ||||
| // Set filename by providing a string for options | ||||
| form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' ); | ||||
| 
 | ||||
| // provide an object. | ||||
| form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} ); | ||||
| ``` | ||||
| 
 | ||||
| #### _Headers_ getHeaders( [**Headers** _userHeaders_] ) | ||||
| This method adds the correct `content-type` header to the provided array of `userHeaders`. | ||||
| 
 | ||||
| #### _String_ getBoundary() | ||||
| Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers | ||||
| for example: | ||||
| ```javascript | ||||
| --------------------------515890814546601021194782 | ||||
| ``` | ||||
| 
 | ||||
| #### _Void_ setBoundary(String _boundary_) | ||||
| Set the boundary string, overriding the default behavior described above. | ||||
| 
 | ||||
| _Note: The boundary must be unique and may not appear in the data._ | ||||
| 
 | ||||
| #### _Buffer_ getBuffer() | ||||
| Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data. | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) ); | ||||
| form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') ); | ||||
| 
 | ||||
| axios.post( 'https://example.com/path/to/api', | ||||
|             form.getBuffer(), | ||||
|             form.getHeaders() | ||||
|           ) | ||||
| ``` | ||||
| **Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error. | ||||
| 
 | ||||
| #### _Integer_ getLengthSync() | ||||
| Same as `getLength` but synchronous. | ||||
| 
 | ||||
| _Note: getLengthSync __doesn't__ calculate streams length._ | ||||
| 
 | ||||
| #### _Integer_ getLength( **function** _callback_ ) | ||||
| Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated | ||||
| ```javascript | ||||
| this.getLength(function(err, length) { | ||||
|   if (err) { | ||||
|     this._error(err); | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   // add content length | ||||
|   request.setHeader('Content-Length', length); | ||||
| 
 | ||||
|   ... | ||||
| }.bind(this)); | ||||
| ``` | ||||
| 
 | ||||
| #### _Boolean_ hasKnownLength() | ||||
| Checks if the length of added values is known. | ||||
| 
 | ||||
| #### _Request_ submit( _params_, **function** _callback_ ) | ||||
| Submit the form to a web application. | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| form.append( 'my_string', 'Hello World' ); | ||||
| 
 | ||||
| form.submit( 'http://example.com/', function(err, res) { | ||||
|   // res – response object (http.IncomingMessage)  // | ||||
|   res.resume(); | ||||
| } ); | ||||
| ``` | ||||
| 
 | ||||
| #### _String_ toString() | ||||
| Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead. | ||||
| 
 | ||||
| ### Integration with other libraries | ||||
| 
 | ||||
| #### Request | ||||
| 
 | ||||
| Form submission using  [request](https://github.com/request/request): | ||||
| 
 | ||||
| ```javascript | ||||
| var formData = { | ||||
|   my_field: 'my_value', | ||||
|   my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), | ||||
| }; | ||||
| 
 | ||||
| request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) { | ||||
|   if (err) { | ||||
|     return console.error('upload failed:', err); | ||||
|   } | ||||
|   console.log('Upload successful!  Server responded with:', body); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads). | ||||
| 
 | ||||
| #### node-fetch | ||||
| 
 | ||||
| You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch): | ||||
| 
 | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| form.append('a', 1); | ||||
| 
 | ||||
| fetch('http://example.com', { method: 'POST', body: form }) | ||||
|     .then(function(res) { | ||||
|         return res.json(); | ||||
|     }).then(function(json) { | ||||
|         console.log(json); | ||||
|     }); | ||||
| ``` | ||||
| 
 | ||||
| #### axios | ||||
| 
 | ||||
| In Node.js you can post a file using [axios](https://github.com/axios/axios): | ||||
| ```javascript | ||||
| const form = new FormData(); | ||||
| const stream = fs.createReadStream(PATH_TO_FILE); | ||||
| 
 | ||||
| form.append('image', stream); | ||||
| 
 | ||||
| // In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders` | ||||
| const formHeaders = form.getHeaders(); | ||||
| 
 | ||||
| axios.post('http://example.com', form, { | ||||
|   headers: { | ||||
|     ...formHeaders, | ||||
|   }, | ||||
| }) | ||||
| .then(response => response) | ||||
| .catch(error => error) | ||||
| ``` | ||||
| 
 | ||||
| ## Notes | ||||
| 
 | ||||
| - ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround. | ||||
| - ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```). | ||||
| - ```submit``` will not add `content-length` if form length is unknown or not calculable. | ||||
| - Starting version `2.x` FormData has dropped support for `node@0.10.x`. | ||||
| - Starting version `3.x` FormData has dropped support for `node@4.x`. | ||||
| 
 | ||||
| ## License | ||||
| 
 | ||||
| Form-Data is released under the [MIT](License) license. | ||||
							
								
								
									
										358
									
								
								node_modules/superagent/node_modules/form-data/Readme.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										358
									
								
								node_modules/superagent/node_modules/form-data/Readme.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,358 @@ | |||
| # Form-Data [](https://www.npmjs.com/package/form-data) [](https://gitter.im/form-data/form-data) | ||||
| 
 | ||||
| A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications. | ||||
| 
 | ||||
| The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd]. | ||||
| 
 | ||||
| [xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface | ||||
| 
 | ||||
| [](https://travis-ci.org/form-data/form-data) | ||||
| [](https://travis-ci.org/form-data/form-data) | ||||
| [](https://travis-ci.org/form-data/form-data) | ||||
| 
 | ||||
| [](https://coveralls.io/github/form-data/form-data?branch=master) | ||||
| [](https://david-dm.org/form-data/form-data) | ||||
| 
 | ||||
| ## Install | ||||
| 
 | ||||
| ``` | ||||
| npm install --save form-data | ||||
| ``` | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| In this example we are constructing a form with 3 fields that contain a string, | ||||
| a buffer and a file stream. | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| var fs = require('fs'); | ||||
| 
 | ||||
| var form = new FormData(); | ||||
| form.append('my_field', 'my value'); | ||||
| form.append('my_buffer', new Buffer(10)); | ||||
| form.append('my_file', fs.createReadStream('/foo/bar.jpg')); | ||||
| ``` | ||||
| 
 | ||||
| Also you can use http-response stream: | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| var http = require('http'); | ||||
| 
 | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| http.request('http://nodejs.org/images/logo.png', function(response) { | ||||
|   form.append('my_field', 'my value'); | ||||
|   form.append('my_buffer', new Buffer(10)); | ||||
|   form.append('my_logo', response); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| Or @mikeal's [request](https://github.com/request/request) stream: | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| var request = require('request'); | ||||
| 
 | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| form.append('my_field', 'my value'); | ||||
| form.append('my_buffer', new Buffer(10)); | ||||
| form.append('my_logo', request('http://nodejs.org/images/logo.png')); | ||||
| ``` | ||||
| 
 | ||||
| In order to submit this form to a web application, call ```submit(url, [callback])``` method: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit('http://example.org/', function(err, res) { | ||||
|   // res – response object (http.IncomingMessage)  // | ||||
|   res.resume(); | ||||
| }); | ||||
| 
 | ||||
| ``` | ||||
| 
 | ||||
| For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods. | ||||
| 
 | ||||
| ### Custom options | ||||
| 
 | ||||
| You can provide custom options, such as `maxDataSize`: | ||||
| 
 | ||||
| ``` javascript | ||||
| var FormData = require('form-data'); | ||||
| 
 | ||||
| var form = new FormData({ maxDataSize: 20971520 }); | ||||
| form.append('my_field', 'my value'); | ||||
| form.append('my_buffer', /* something big */); | ||||
| ``` | ||||
| 
 | ||||
| List of available options could be found in [combined-stream](https://github.com/felixge/node-combined-stream/blob/master/lib/combined_stream.js#L7-L15) | ||||
| 
 | ||||
| ### Alternative submission methods | ||||
| 
 | ||||
| You can use node's http client interface: | ||||
| 
 | ||||
| ``` javascript | ||||
| var http = require('http'); | ||||
| 
 | ||||
| var request = http.request({ | ||||
|   method: 'post', | ||||
|   host: 'example.org', | ||||
|   path: '/upload', | ||||
|   headers: form.getHeaders() | ||||
| }); | ||||
| 
 | ||||
| form.pipe(request); | ||||
| 
 | ||||
| request.on('response', function(res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| Or if you would prefer the `'Content-Length'` header to be set for you: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit('example.org/upload', function(err, res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| To use custom headers and pre-known length in parts: | ||||
| 
 | ||||
| ``` javascript | ||||
| var CRLF = '\r\n'; | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| var options = { | ||||
|   header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF, | ||||
|   knownLength: 1 | ||||
| }; | ||||
| 
 | ||||
| form.append('my_buffer', buffer, options); | ||||
| 
 | ||||
| form.submit('http://example.com/', function(err, res) { | ||||
|   if (err) throw err; | ||||
|   console.log('Done'); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually: | ||||
| 
 | ||||
| ``` javascript | ||||
| someModule.stream(function(err, stdout, stderr) { | ||||
|   if (err) throw err; | ||||
| 
 | ||||
|   var form = new FormData(); | ||||
| 
 | ||||
|   form.append('file', stdout, { | ||||
|     filename: 'unicycle.jpg', // ... or: | ||||
|     filepath: 'photos/toys/unicycle.jpg', | ||||
|     contentType: 'image/jpeg', | ||||
|     knownLength: 19806 | ||||
|   }); | ||||
| 
 | ||||
|   form.submit('http://example.com/', function(err, res) { | ||||
|     if (err) throw err; | ||||
|     console.log('Done'); | ||||
|   }); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| The `filepath` property overrides `filename` and may contain a relative path. This is typically used when uploading [multiple files from a directory](https://wicg.github.io/entries-api/#dom-htmlinputelement-webkitdirectory). | ||||
| 
 | ||||
| For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit({ | ||||
|   host: 'example.com', | ||||
|   path: '/probably.php?extra=params', | ||||
|   auth: 'username:password' | ||||
| }, function(err, res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`: | ||||
| 
 | ||||
| ``` javascript | ||||
| form.submit({ | ||||
|   host: 'example.com', | ||||
|   path: '/surelynot.php', | ||||
|   headers: {'x-test-header': 'test-header-value'} | ||||
| }, function(err, res) { | ||||
|   console.log(res.statusCode); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| ### Methods | ||||
| 
 | ||||
| - [_Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] )](https://github.com/form-data/form-data#void-append-string-field-mixed-value--mixed-options-). | ||||
| - [_Headers_ getHeaders( [**Headers** _userHeaders_] )](https://github.com/form-data/form-data#array-getheaders-array-userheaders-) | ||||
| - [_String_ getBoundary()](https://github.com/form-data/form-data#string-getboundary) | ||||
| - [_Void_ setBoundary()](https://github.com/form-data/form-data#void-setboundary) | ||||
| - [_Buffer_ getBuffer()](https://github.com/form-data/form-data#buffer-getbuffer) | ||||
| - [_Integer_ getLengthSync()](https://github.com/form-data/form-data#integer-getlengthsync) | ||||
| - [_Integer_ getLength( **function** _callback_ )](https://github.com/form-data/form-data#integer-getlength-function-callback-) | ||||
| - [_Boolean_ hasKnownLength()](https://github.com/form-data/form-data#boolean-hasknownlength) | ||||
| - [_Request_ submit( _params_, **function** _callback_ )](https://github.com/form-data/form-data#request-submit-params-function-callback-) | ||||
| - [_String_ toString()](https://github.com/form-data/form-data#string-tostring) | ||||
| 
 | ||||
| #### _Void_ append( **String** _field_, **Mixed** _value_ [, **Mixed** _options_] ) | ||||
| Append data to the form. You can submit about any format (string, integer, boolean, buffer, etc.). However, Arrays are not supported and need to be turned into strings by the user. | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| form.append( 'my_string', 'my value' ); | ||||
| form.append( 'my_integer', 1 ); | ||||
| form.append( 'my_boolean', true ); | ||||
| form.append( 'my_buffer', new Buffer(10) ); | ||||
| form.append( 'my_array_as_json', JSON.stringify( ['bird','cute'] ) ) | ||||
| ``` | ||||
| 
 | ||||
| You may provide a string for options, or an object. | ||||
| ```javascript | ||||
| // Set filename by providing a string for options | ||||
| form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), 'bar.jpg' ); | ||||
| 
 | ||||
| // provide an object. | ||||
| form.append( 'my_file', fs.createReadStream('/foo/bar.jpg'), {filename: 'bar.jpg', contentType: 'image/jpeg', knownLength: 19806} ); | ||||
| ``` | ||||
| 
 | ||||
| #### _Headers_ getHeaders( [**Headers** _userHeaders_] ) | ||||
| This method adds the correct `content-type` header to the provided array of `userHeaders`. | ||||
| 
 | ||||
| #### _String_ getBoundary() | ||||
| Return the boundary of the formData. By default, the boundary consists of 26 `-` followed by 24 numbers | ||||
| for example: | ||||
| ```javascript | ||||
| --------------------------515890814546601021194782 | ||||
| ``` | ||||
| 
 | ||||
| #### _Void_ setBoundary(String _boundary_) | ||||
| Set the boundary string, overriding the default behavior described above. | ||||
| 
 | ||||
| _Note: The boundary must be unique and may not appear in the data._ | ||||
| 
 | ||||
| #### _Buffer_ getBuffer() | ||||
| Return the full formdata request package, as a Buffer. You can insert this Buffer in e.g. Axios to send multipart data. | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| form.append( 'my_buffer', Buffer.from([0x4a,0x42,0x20,0x52,0x6f,0x63,0x6b,0x73]) ); | ||||
| form.append( 'my_file', fs.readFileSync('/foo/bar.jpg') ); | ||||
| 
 | ||||
| axios.post( 'https://example.com/path/to/api', | ||||
|             form.getBuffer(), | ||||
|             form.getHeaders() | ||||
|           ) | ||||
| ``` | ||||
| **Note:** Because the output is of type Buffer, you can only append types that are accepted by Buffer: *string, Buffer, ArrayBuffer, Array, or Array-like Object*. A ReadStream for example will result in an error. | ||||
| 
 | ||||
| #### _Integer_ getLengthSync() | ||||
| Same as `getLength` but synchronous. | ||||
| 
 | ||||
| _Note: getLengthSync __doesn't__ calculate streams length._ | ||||
| 
 | ||||
| #### _Integer_ getLength( **function** _callback_ ) | ||||
| Returns the `Content-Length` async. The callback is used to handle errors and continue once the length has been calculated | ||||
| ```javascript | ||||
| this.getLength(function(err, length) { | ||||
|   if (err) { | ||||
|     this._error(err); | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   // add content length | ||||
|   request.setHeader('Content-Length', length); | ||||
| 
 | ||||
|   ... | ||||
| }.bind(this)); | ||||
| ``` | ||||
| 
 | ||||
| #### _Boolean_ hasKnownLength() | ||||
| Checks if the length of added values is known. | ||||
| 
 | ||||
| #### _Request_ submit( _params_, **function** _callback_ ) | ||||
| Submit the form to a web application. | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| form.append( 'my_string', 'Hello World' ); | ||||
| 
 | ||||
| form.submit( 'http://example.com/', function(err, res) { | ||||
|   // res – response object (http.IncomingMessage)  // | ||||
|   res.resume(); | ||||
| } ); | ||||
| ``` | ||||
| 
 | ||||
| #### _String_ toString() | ||||
| Returns the form data as a string. Don't use this if you are sending files or buffers, use `getBuffer()` instead. | ||||
| 
 | ||||
| ### Integration with other libraries | ||||
| 
 | ||||
| #### Request | ||||
| 
 | ||||
| Form submission using  [request](https://github.com/request/request): | ||||
| 
 | ||||
| ```javascript | ||||
| var formData = { | ||||
|   my_field: 'my_value', | ||||
|   my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), | ||||
| }; | ||||
| 
 | ||||
| request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) { | ||||
|   if (err) { | ||||
|     return console.error('upload failed:', err); | ||||
|   } | ||||
|   console.log('Upload successful!  Server responded with:', body); | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads). | ||||
| 
 | ||||
| #### node-fetch | ||||
| 
 | ||||
| You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch): | ||||
| 
 | ||||
| ```javascript | ||||
| var form = new FormData(); | ||||
| 
 | ||||
| form.append('a', 1); | ||||
| 
 | ||||
| fetch('http://example.com', { method: 'POST', body: form }) | ||||
|     .then(function(res) { | ||||
|         return res.json(); | ||||
|     }).then(function(json) { | ||||
|         console.log(json); | ||||
|     }); | ||||
| ``` | ||||
| 
 | ||||
| #### axios | ||||
| 
 | ||||
| In Node.js you can post a file using [axios](https://github.com/axios/axios): | ||||
| ```javascript | ||||
| const form = new FormData(); | ||||
| const stream = fs.createReadStream(PATH_TO_FILE); | ||||
| 
 | ||||
| form.append('image', stream); | ||||
| 
 | ||||
| // In Node.js environment you need to set boundary in the header field 'Content-Type' by calling method `getHeaders` | ||||
| const formHeaders = form.getHeaders(); | ||||
| 
 | ||||
| axios.post('http://example.com', form, { | ||||
|   headers: { | ||||
|     ...formHeaders, | ||||
|   }, | ||||
| }) | ||||
| .then(response => response) | ||||
| .catch(error => error) | ||||
| ``` | ||||
| 
 | ||||
| ## Notes | ||||
| 
 | ||||
| - ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround. | ||||
| - ```getLength(cb)``` will send an error as first parameter of callback if stream length cannot be calculated (e.g. send in custom streams w/o using ```knownLength```). | ||||
| - ```submit``` will not add `content-length` if form length is unknown or not calculable. | ||||
| - Starting version `2.x` FormData has dropped support for `node@0.10.x`. | ||||
| - Starting version `3.x` FormData has dropped support for `node@4.x`. | ||||
| 
 | ||||
| ## License | ||||
| 
 | ||||
| Form-Data is released under the [MIT](License) license. | ||||
							
								
								
									
										62
									
								
								node_modules/superagent/node_modules/form-data/index.d.ts
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								node_modules/superagent/node_modules/form-data/index.d.ts
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,62 @@ | |||
| // Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>
 | ||||
| //                 Leon Yu <https://github.com/leonyu>
 | ||||
| //                 BendingBender <https://github.com/BendingBender>
 | ||||
| //                 Maple Miao <https://github.com/mapleeit>
 | ||||
| 
 | ||||
| /// <reference types="node" />
 | ||||
| import * as stream from 'stream'; | ||||
| import * as http from 'http'; | ||||
| 
 | ||||
| export = FormData; | ||||
| 
 | ||||
| // Extracted because @types/node doesn't export interfaces.
 | ||||
| interface ReadableOptions { | ||||
|   highWaterMark?: number; | ||||
|   encoding?: string; | ||||
|   objectMode?: boolean; | ||||
|   read?(this: stream.Readable, size: number): void; | ||||
|   destroy?(this: stream.Readable, error: Error | null, callback: (error: Error | null) => void): void; | ||||
|   autoDestroy?: boolean; | ||||
| } | ||||
| 
 | ||||
| interface Options extends ReadableOptions { | ||||
|   writable?: boolean; | ||||
|   readable?: boolean; | ||||
|   dataSize?: number; | ||||
|   maxDataSize?: number; | ||||
|   pauseStreams?: boolean; | ||||
| } | ||||
| 
 | ||||
| declare class FormData extends stream.Readable { | ||||
|   constructor(options?: Options); | ||||
|   append(key: string, value: any, options?: FormData.AppendOptions | string): void; | ||||
|   getHeaders(userHeaders?: FormData.Headers): FormData.Headers; | ||||
|   submit( | ||||
|     params: string | FormData.SubmitOptions, | ||||
|     callback?: (error: Error | null, response: http.IncomingMessage) => void | ||||
|   ): http.ClientRequest; | ||||
|   getBuffer(): Buffer; | ||||
|   setBoundary(boundary: string): void; | ||||
|   getBoundary(): string; | ||||
|   getLength(callback: (err: Error | null, length: number) => void): void; | ||||
|   getLengthSync(): number; | ||||
|   hasKnownLength(): boolean; | ||||
| } | ||||
| 
 | ||||
| declare namespace FormData { | ||||
|   interface Headers { | ||||
|     [key: string]: any; | ||||
|   } | ||||
| 
 | ||||
|   interface AppendOptions { | ||||
|     header?: string | Headers; | ||||
|     knownLength?: number; | ||||
|     filename?: string; | ||||
|     filepath?: string; | ||||
|     contentType?: string; | ||||
|   } | ||||
| 
 | ||||
|   interface SubmitOptions extends http.RequestOptions { | ||||
|     protocol?: 'https:' | 'http:'; | ||||
|   } | ||||
| } | ||||
							
								
								
									
										2
									
								
								node_modules/superagent/node_modules/form-data/lib/browser.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								node_modules/superagent/node_modules/form-data/lib/browser.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,2 @@ | |||
| /* eslint-env browser */ | ||||
| module.exports = typeof self == 'object' ? self.FormData : window.FormData; | ||||
							
								
								
									
										501
									
								
								node_modules/superagent/node_modules/form-data/lib/form_data.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										501
									
								
								node_modules/superagent/node_modules/form-data/lib/form_data.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,501 @@ | |||
| var CombinedStream = require('combined-stream'); | ||||
| var util = require('util'); | ||||
| var path = require('path'); | ||||
| var http = require('http'); | ||||
| var https = require('https'); | ||||
| var parseUrl = require('url').parse; | ||||
| var fs = require('fs'); | ||||
| var Stream = require('stream').Stream; | ||||
| var mime = require('mime-types'); | ||||
| var asynckit = require('asynckit'); | ||||
| var populate = require('./populate.js'); | ||||
| 
 | ||||
| // Public API
 | ||||
| module.exports = FormData; | ||||
| 
 | ||||
| // make it a Stream
 | ||||
| util.inherits(FormData, CombinedStream); | ||||
| 
 | ||||
| /** | ||||
|  * Create readable "multipart/form-data" streams. | ||||
|  * Can be used to submit forms | ||||
|  * and file uploads to other web applications. | ||||
|  * | ||||
|  * @constructor | ||||
|  * @param {Object} options - Properties to be added/overriden for FormData and CombinedStream | ||||
|  */ | ||||
| function FormData(options) { | ||||
|   if (!(this instanceof FormData)) { | ||||
|     return new FormData(options); | ||||
|   } | ||||
| 
 | ||||
|   this._overheadLength = 0; | ||||
|   this._valueLength = 0; | ||||
|   this._valuesToMeasure = []; | ||||
| 
 | ||||
|   CombinedStream.call(this); | ||||
| 
 | ||||
|   options = options || {}; | ||||
|   for (var option in options) { | ||||
|     this[option] = options[option]; | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| FormData.LINE_BREAK = '\r\n'; | ||||
| FormData.DEFAULT_CONTENT_TYPE = 'application/octet-stream'; | ||||
| 
 | ||||
| FormData.prototype.append = function(field, value, options) { | ||||
| 
 | ||||
|   options = options || {}; | ||||
| 
 | ||||
|   // allow filename as single option
 | ||||
|   if (typeof options == 'string') { | ||||
|     options = {filename: options}; | ||||
|   } | ||||
| 
 | ||||
|   var append = CombinedStream.prototype.append.bind(this); | ||||
| 
 | ||||
|   // all that streamy business can't handle numbers
 | ||||
|   if (typeof value == 'number') { | ||||
|     value = '' + value; | ||||
|   } | ||||
| 
 | ||||
|   // https://github.com/felixge/node-form-data/issues/38
 | ||||
|   if (util.isArray(value)) { | ||||
|     // Please convert your array into string
 | ||||
|     // the way web server expects it
 | ||||
|     this._error(new Error('Arrays are not supported.')); | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   var header = this._multiPartHeader(field, value, options); | ||||
|   var footer = this._multiPartFooter(); | ||||
| 
 | ||||
|   append(header); | ||||
|   append(value); | ||||
|   append(footer); | ||||
| 
 | ||||
|   // pass along options.knownLength
 | ||||
|   this._trackLength(header, value, options); | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._trackLength = function(header, value, options) { | ||||
|   var valueLength = 0; | ||||
| 
 | ||||
|   // used w/ getLengthSync(), when length is known.
 | ||||
|   // e.g. for streaming directly from a remote server,
 | ||||
|   // w/ a known file a size, and not wanting to wait for
 | ||||
|   // incoming file to finish to get its size.
 | ||||
|   if (options.knownLength != null) { | ||||
|     valueLength += +options.knownLength; | ||||
|   } else if (Buffer.isBuffer(value)) { | ||||
|     valueLength = value.length; | ||||
|   } else if (typeof value === 'string') { | ||||
|     valueLength = Buffer.byteLength(value); | ||||
|   } | ||||
| 
 | ||||
|   this._valueLength += valueLength; | ||||
| 
 | ||||
|   // @check why add CRLF? does this account for custom/multiple CRLFs?
 | ||||
|   this._overheadLength += | ||||
|     Buffer.byteLength(header) + | ||||
|     FormData.LINE_BREAK.length; | ||||
| 
 | ||||
|   // empty or either doesn't have path or not an http response or not a stream
 | ||||
|   if (!value || ( !value.path && !(value.readable && value.hasOwnProperty('httpVersion')) && !(value instanceof Stream))) { | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   // no need to bother with the length
 | ||||
|   if (!options.knownLength) { | ||||
|     this._valuesToMeasure.push(value); | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._lengthRetriever = function(value, callback) { | ||||
| 
 | ||||
|   if (value.hasOwnProperty('fd')) { | ||||
| 
 | ||||
|     // take read range into a account
 | ||||
|     // `end` = Infinity –> read file till the end
 | ||||
|     //
 | ||||
|     // TODO: Looks like there is bug in Node fs.createReadStream
 | ||||
|     // it doesn't respect `end` options without `start` options
 | ||||
|     // Fix it when node fixes it.
 | ||||
|     // https://github.com/joyent/node/issues/7819
 | ||||
|     if (value.end != undefined && value.end != Infinity && value.start != undefined) { | ||||
| 
 | ||||
|       // when end specified
 | ||||
|       // no need to calculate range
 | ||||
|       // inclusive, starts with 0
 | ||||
|       callback(null, value.end + 1 - (value.start ? value.start : 0)); | ||||
| 
 | ||||
|     // not that fast snoopy
 | ||||
|     } else { | ||||
|       // still need to fetch file size from fs
 | ||||
|       fs.stat(value.path, function(err, stat) { | ||||
| 
 | ||||
|         var fileSize; | ||||
| 
 | ||||
|         if (err) { | ||||
|           callback(err); | ||||
|           return; | ||||
|         } | ||||
| 
 | ||||
|         // update final size based on the range options
 | ||||
|         fileSize = stat.size - (value.start ? value.start : 0); | ||||
|         callback(null, fileSize); | ||||
|       }); | ||||
|     } | ||||
| 
 | ||||
|   // or http response
 | ||||
|   } else if (value.hasOwnProperty('httpVersion')) { | ||||
|     callback(null, +value.headers['content-length']); | ||||
| 
 | ||||
|   // or request stream http://github.com/mikeal/request
 | ||||
|   } else if (value.hasOwnProperty('httpModule')) { | ||||
|     // wait till response come back
 | ||||
|     value.on('response', function(response) { | ||||
|       value.pause(); | ||||
|       callback(null, +response.headers['content-length']); | ||||
|     }); | ||||
|     value.resume(); | ||||
| 
 | ||||
|   // something else
 | ||||
|   } else { | ||||
|     callback('Unknown stream'); | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._multiPartHeader = function(field, value, options) { | ||||
|   // custom header specified (as string)?
 | ||||
|   // it becomes responsible for boundary
 | ||||
|   // (e.g. to handle extra CRLFs on .NET servers)
 | ||||
|   if (typeof options.header == 'string') { | ||||
|     return options.header; | ||||
|   } | ||||
| 
 | ||||
|   var contentDisposition = this._getContentDisposition(value, options); | ||||
|   var contentType = this._getContentType(value, options); | ||||
| 
 | ||||
|   var contents = ''; | ||||
|   var headers  = { | ||||
|     // add custom disposition as third element or keep it two elements if not
 | ||||
|     'Content-Disposition': ['form-data', 'name="' + field + '"'].concat(contentDisposition || []), | ||||
|     // if no content type. allow it to be empty array
 | ||||
|     'Content-Type': [].concat(contentType || []) | ||||
|   }; | ||||
| 
 | ||||
|   // allow custom headers.
 | ||||
|   if (typeof options.header == 'object') { | ||||
|     populate(headers, options.header); | ||||
|   } | ||||
| 
 | ||||
|   var header; | ||||
|   for (var prop in headers) { | ||||
|     if (!headers.hasOwnProperty(prop)) continue; | ||||
|     header = headers[prop]; | ||||
| 
 | ||||
|     // skip nullish headers.
 | ||||
|     if (header == null) { | ||||
|       continue; | ||||
|     } | ||||
| 
 | ||||
|     // convert all headers to arrays.
 | ||||
|     if (!Array.isArray(header)) { | ||||
|       header = [header]; | ||||
|     } | ||||
| 
 | ||||
|     // add non-empty headers.
 | ||||
|     if (header.length) { | ||||
|       contents += prop + ': ' + header.join('; ') + FormData.LINE_BREAK; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   return '--' + this.getBoundary() + FormData.LINE_BREAK + contents + FormData.LINE_BREAK; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._getContentDisposition = function(value, options) { | ||||
| 
 | ||||
|   var filename | ||||
|     , contentDisposition | ||||
|     ; | ||||
| 
 | ||||
|   if (typeof options.filepath === 'string') { | ||||
|     // custom filepath for relative paths
 | ||||
|     filename = path.normalize(options.filepath).replace(/\\/g, '/'); | ||||
|   } else if (options.filename || value.name || value.path) { | ||||
|     // custom filename take precedence
 | ||||
|     // formidable and the browser add a name property
 | ||||
|     // fs- and request- streams have path property
 | ||||
|     filename = path.basename(options.filename || value.name || value.path); | ||||
|   } else if (value.readable && value.hasOwnProperty('httpVersion')) { | ||||
|     // or try http response
 | ||||
|     filename = path.basename(value.client._httpMessage.path || ''); | ||||
|   } | ||||
| 
 | ||||
|   if (filename) { | ||||
|     contentDisposition = 'filename="' + filename + '"'; | ||||
|   } | ||||
| 
 | ||||
|   return contentDisposition; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._getContentType = function(value, options) { | ||||
| 
 | ||||
|   // use custom content-type above all
 | ||||
|   var contentType = options.contentType; | ||||
| 
 | ||||
|   // or try `name` from formidable, browser
 | ||||
|   if (!contentType && value.name) { | ||||
|     contentType = mime.lookup(value.name); | ||||
|   } | ||||
| 
 | ||||
|   // or try `path` from fs-, request- streams
 | ||||
|   if (!contentType && value.path) { | ||||
|     contentType = mime.lookup(value.path); | ||||
|   } | ||||
| 
 | ||||
|   // or if it's http-reponse
 | ||||
|   if (!contentType && value.readable && value.hasOwnProperty('httpVersion')) { | ||||
|     contentType = value.headers['content-type']; | ||||
|   } | ||||
| 
 | ||||
|   // or guess it from the filepath or filename
 | ||||
|   if (!contentType && (options.filepath || options.filename)) { | ||||
|     contentType = mime.lookup(options.filepath || options.filename); | ||||
|   } | ||||
| 
 | ||||
|   // fallback to the default content type if `value` is not simple value
 | ||||
|   if (!contentType && typeof value == 'object') { | ||||
|     contentType = FormData.DEFAULT_CONTENT_TYPE; | ||||
|   } | ||||
| 
 | ||||
|   return contentType; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._multiPartFooter = function() { | ||||
|   return function(next) { | ||||
|     var footer = FormData.LINE_BREAK; | ||||
| 
 | ||||
|     var lastPart = (this._streams.length === 0); | ||||
|     if (lastPart) { | ||||
|       footer += this._lastBoundary(); | ||||
|     } | ||||
| 
 | ||||
|     next(footer); | ||||
|   }.bind(this); | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._lastBoundary = function() { | ||||
|   return '--' + this.getBoundary() + '--' + FormData.LINE_BREAK; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype.getHeaders = function(userHeaders) { | ||||
|   var header; | ||||
|   var formHeaders = { | ||||
|     'content-type': 'multipart/form-data; boundary=' + this.getBoundary() | ||||
|   }; | ||||
| 
 | ||||
|   for (header in userHeaders) { | ||||
|     if (userHeaders.hasOwnProperty(header)) { | ||||
|       formHeaders[header.toLowerCase()] = userHeaders[header]; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   return formHeaders; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype.setBoundary = function(boundary) { | ||||
|   this._boundary = boundary; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype.getBoundary = function() { | ||||
|   if (!this._boundary) { | ||||
|     this._generateBoundary(); | ||||
|   } | ||||
| 
 | ||||
|   return this._boundary; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype.getBuffer = function() { | ||||
|   var dataBuffer = new Buffer.alloc( 0 ); | ||||
|   var boundary = this.getBoundary(); | ||||
| 
 | ||||
|   // Create the form content. Add Line breaks to the end of data.
 | ||||
|   for (var i = 0, len = this._streams.length; i < len; i++) { | ||||
|     if (typeof this._streams[i] !== 'function') { | ||||
| 
 | ||||
|       // Add content to the buffer.
 | ||||
|       if(Buffer.isBuffer(this._streams[i])) { | ||||
|         dataBuffer = Buffer.concat( [dataBuffer, this._streams[i]]); | ||||
|       }else { | ||||
|         dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(this._streams[i])]); | ||||
|       } | ||||
| 
 | ||||
|       // Add break after content.
 | ||||
|       if (typeof this._streams[i] !== 'string' || this._streams[i].substring( 2, boundary.length + 2 ) !== boundary) { | ||||
|         dataBuffer = Buffer.concat( [dataBuffer, Buffer.from(FormData.LINE_BREAK)] ); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // Add the footer and return the Buffer object.
 | ||||
|   return Buffer.concat( [dataBuffer, Buffer.from(this._lastBoundary())] ); | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._generateBoundary = function() { | ||||
|   // This generates a 50 character boundary similar to those used by Firefox.
 | ||||
|   // They are optimized for boyer-moore parsing.
 | ||||
|   var boundary = '--------------------------'; | ||||
|   for (var i = 0; i < 24; i++) { | ||||
|     boundary += Math.floor(Math.random() * 10).toString(16); | ||||
|   } | ||||
| 
 | ||||
|   this._boundary = boundary; | ||||
| }; | ||||
| 
 | ||||
| // Note: getLengthSync DOESN'T calculate streams length
 | ||||
| // As workaround one can calculate file size manually
 | ||||
| // and add it as knownLength option
 | ||||
| FormData.prototype.getLengthSync = function() { | ||||
|   var knownLength = this._overheadLength + this._valueLength; | ||||
| 
 | ||||
|   // Don't get confused, there are 3 "internal" streams for each keyval pair
 | ||||
|   // so it basically checks if there is any value added to the form
 | ||||
|   if (this._streams.length) { | ||||
|     knownLength += this._lastBoundary().length; | ||||
|   } | ||||
| 
 | ||||
|   // https://github.com/form-data/form-data/issues/40
 | ||||
|   if (!this.hasKnownLength()) { | ||||
|     // Some async length retrievers are present
 | ||||
|     // therefore synchronous length calculation is false.
 | ||||
|     // Please use getLength(callback) to get proper length
 | ||||
|     this._error(new Error('Cannot calculate proper length in synchronous way.')); | ||||
|   } | ||||
| 
 | ||||
|   return knownLength; | ||||
| }; | ||||
| 
 | ||||
| // Public API to check if length of added values is known
 | ||||
| // https://github.com/form-data/form-data/issues/196
 | ||||
| // https://github.com/form-data/form-data/issues/262
 | ||||
| FormData.prototype.hasKnownLength = function() { | ||||
|   var hasKnownLength = true; | ||||
| 
 | ||||
|   if (this._valuesToMeasure.length) { | ||||
|     hasKnownLength = false; | ||||
|   } | ||||
| 
 | ||||
|   return hasKnownLength; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype.getLength = function(cb) { | ||||
|   var knownLength = this._overheadLength + this._valueLength; | ||||
| 
 | ||||
|   if (this._streams.length) { | ||||
|     knownLength += this._lastBoundary().length; | ||||
|   } | ||||
| 
 | ||||
|   if (!this._valuesToMeasure.length) { | ||||
|     process.nextTick(cb.bind(this, null, knownLength)); | ||||
|     return; | ||||
|   } | ||||
| 
 | ||||
|   asynckit.parallel(this._valuesToMeasure, this._lengthRetriever, function(err, values) { | ||||
|     if (err) { | ||||
|       cb(err); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     values.forEach(function(length) { | ||||
|       knownLength += length; | ||||
|     }); | ||||
| 
 | ||||
|     cb(null, knownLength); | ||||
|   }); | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype.submit = function(params, cb) { | ||||
|   var request | ||||
|     , options | ||||
|     , defaults = {method: 'post'} | ||||
|     ; | ||||
| 
 | ||||
|   // parse provided url if it's string
 | ||||
|   // or treat it as options object
 | ||||
|   if (typeof params == 'string') { | ||||
| 
 | ||||
|     params = parseUrl(params); | ||||
|     options = populate({ | ||||
|       port: params.port, | ||||
|       path: params.pathname, | ||||
|       host: params.hostname, | ||||
|       protocol: params.protocol | ||||
|     }, defaults); | ||||
| 
 | ||||
|   // use custom params
 | ||||
|   } else { | ||||
| 
 | ||||
|     options = populate(params, defaults); | ||||
|     // if no port provided use default one
 | ||||
|     if (!options.port) { | ||||
|       options.port = options.protocol == 'https:' ? 443 : 80; | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   // put that good code in getHeaders to some use
 | ||||
|   options.headers = this.getHeaders(params.headers); | ||||
| 
 | ||||
|   // https if specified, fallback to http in any other case
 | ||||
|   if (options.protocol == 'https:') { | ||||
|     request = https.request(options); | ||||
|   } else { | ||||
|     request = http.request(options); | ||||
|   } | ||||
| 
 | ||||
|   // get content length and fire away
 | ||||
|   this.getLength(function(err, length) { | ||||
|     if (err && err !== 'Unknown stream') { | ||||
|       this._error(err); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     // add content length
 | ||||
|     if (length) { | ||||
|       request.setHeader('Content-Length', length); | ||||
|     } | ||||
| 
 | ||||
|     this.pipe(request); | ||||
|     if (cb) { | ||||
|       var onResponse; | ||||
| 
 | ||||
|       var callback = function (error, responce) { | ||||
|         request.removeListener('error', callback); | ||||
|         request.removeListener('response', onResponse); | ||||
| 
 | ||||
|         return cb.call(this, error, responce); | ||||
|       }; | ||||
| 
 | ||||
|       onResponse = callback.bind(this, null); | ||||
| 
 | ||||
|       request.on('error', callback); | ||||
|       request.on('response', onResponse); | ||||
|     } | ||||
|   }.bind(this)); | ||||
| 
 | ||||
|   return request; | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype._error = function(err) { | ||||
|   if (!this.error) { | ||||
|     this.error = err; | ||||
|     this.pause(); | ||||
|     this.emit('error', err); | ||||
|   } | ||||
| }; | ||||
| 
 | ||||
| FormData.prototype.toString = function () { | ||||
|   return '[object FormData]'; | ||||
| }; | ||||
							
								
								
									
										10
									
								
								node_modules/superagent/node_modules/form-data/lib/populate.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								node_modules/superagent/node_modules/form-data/lib/populate.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,10 @@ | |||
| // populates missing values
 | ||||
| module.exports = function(dst, src) { | ||||
| 
 | ||||
|   Object.keys(src).forEach(function(prop) | ||||
|   { | ||||
|     dst[prop] = dst[prop] || src[prop]; | ||||
|   }); | ||||
| 
 | ||||
|   return dst; | ||||
| }; | ||||
							
								
								
									
										68
									
								
								node_modules/superagent/node_modules/form-data/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								node_modules/superagent/node_modules/form-data/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,68 @@ | |||
| { | ||||
|   "author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)", | ||||
|   "name": "form-data", | ||||
|   "description": "A library to create readable \"multipart/form-data\" streams. Can be used to submit forms and file uploads to other web applications.", | ||||
|   "version": "4.0.0", | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git://github.com/form-data/form-data.git" | ||||
|   }, | ||||
|   "main": "./lib/form_data", | ||||
|   "browser": "./lib/browser", | ||||
|   "typings": "./index.d.ts", | ||||
|   "scripts": { | ||||
|     "pretest": "rimraf coverage test/tmp", | ||||
|     "test": "istanbul cover test/run.js", | ||||
|     "posttest": "istanbul report lcov text", | ||||
|     "lint": "eslint lib/*.js test/*.js test/integration/*.js", | ||||
|     "report": "istanbul report lcov text", | ||||
|     "ci-lint": "is-node-modern 8 && npm run lint || is-node-not-modern 8", | ||||
|     "ci-test": "npm run test && npm run browser && npm run report", | ||||
|     "predebug": "rimraf coverage test/tmp", | ||||
|     "debug": "verbose=1 ./test/run.js", | ||||
|     "browser": "browserify -t browserify-istanbul test/run-browser.js | obake --coverage", | ||||
|     "check": "istanbul check-coverage coverage/coverage*.json", | ||||
|     "files": "pkgfiles --sort=name", | ||||
|     "get-version": "node -e \"console.log(require('./package.json').version)\"", | ||||
|     "update-readme": "sed -i.bak 's/\\/master\\.svg/\\/v'$(npm --silent run get-version)'.svg/g' README.md", | ||||
|     "restore-readme": "mv README.md.bak README.md", | ||||
|     "prepublish": "in-publish && npm run update-readme || not-in-publish", | ||||
|     "postpublish": "npm run restore-readme" | ||||
|   }, | ||||
|   "pre-commit": [ | ||||
|     "lint", | ||||
|     "ci-test", | ||||
|     "check" | ||||
|   ], | ||||
|   "engines": { | ||||
|     "node": ">= 6" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "asynckit": "^0.4.0", | ||||
|     "combined-stream": "^1.0.8", | ||||
|     "mime-types": "^2.1.12" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/node": "^12.0.10", | ||||
|     "browserify": "^13.1.1", | ||||
|     "browserify-istanbul": "^2.0.0", | ||||
|     "coveralls": "^3.0.4", | ||||
|     "cross-spawn": "^6.0.5", | ||||
|     "eslint": "^6.0.1", | ||||
|     "fake": "^0.2.2", | ||||
|     "far": "^0.0.7", | ||||
|     "formidable": "^1.0.17", | ||||
|     "in-publish": "^2.0.0", | ||||
|     "is-node-modern": "^1.0.0", | ||||
|     "istanbul": "^0.4.5", | ||||
|     "obake": "^0.1.2", | ||||
|     "puppeteer": "^1.19.0", | ||||
|     "pkgfiles": "^2.3.0", | ||||
|     "pre-commit": "^1.1.3", | ||||
|     "request": "^2.88.0", | ||||
|     "rimraf": "^2.7.1", | ||||
|     "tape": "^4.6.2", | ||||
|     "typescript": "^3.5.2" | ||||
|   }, | ||||
|   "license": "MIT" | ||||
| } | ||||
							
								
								
									
										43
									
								
								node_modules/superagent/node_modules/qs/.editorconfig
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								node_modules/superagent/node_modules/qs/.editorconfig
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | |||
| root = true | ||||
| 
 | ||||
| [*] | ||||
| indent_style = space | ||||
| indent_size = 4 | ||||
| end_of_line = lf | ||||
| charset = utf-8 | ||||
| trim_trailing_whitespace = true | ||||
| insert_final_newline = true | ||||
| max_line_length = 160 | ||||
| quote_type = single | ||||
| 
 | ||||
| [test/*] | ||||
| max_line_length = off | ||||
| 
 | ||||
| [LICENSE.md] | ||||
| indent_size = off | ||||
| 
 | ||||
| [*.md] | ||||
| max_line_length = off | ||||
| 
 | ||||
| [*.json] | ||||
| max_line_length = off | ||||
| 
 | ||||
| [Makefile] | ||||
| max_line_length = off | ||||
| 
 | ||||
| [CHANGELOG.md] | ||||
| indent_style = space | ||||
| indent_size = 2 | ||||
| 
 | ||||
| [LICENSE] | ||||
| indent_size = 2 | ||||
| max_line_length = off | ||||
| 
 | ||||
| [coverage/**/*] | ||||
| indent_size = off | ||||
| indent_style = off | ||||
| indent = off | ||||
| max_line_length = off | ||||
| 
 | ||||
| [.nycrc] | ||||
| indent_style = tab | ||||
							
								
								
									
										38
									
								
								node_modules/superagent/node_modules/qs/.eslintrc
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								node_modules/superagent/node_modules/qs/.eslintrc
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,38 @@ | |||
| { | ||||
|     "root": true, | ||||
| 
 | ||||
|     "extends": "@ljharb", | ||||
| 
 | ||||
|     "ignorePatterns": [ | ||||
|         "dist/", | ||||
|     ], | ||||
| 
 | ||||
|     "rules": { | ||||
|         "complexity": 0, | ||||
|         "consistent-return": 1, | ||||
|         "func-name-matching": 0, | ||||
|         "id-length": [2, { "min": 1, "max": 25, "properties": "never" }], | ||||
|         "indent": [2, 4], | ||||
|         "max-lines-per-function": [2, { "max": 150 }], | ||||
|         "max-params": [2, 16], | ||||
|         "max-statements": [2, 53], | ||||
|         "multiline-comment-style": 0, | ||||
|         "no-continue": 1, | ||||
|         "no-magic-numbers": 0, | ||||
|         "no-restricted-syntax": [2, "BreakStatement", "DebuggerStatement", "ForInStatement", "LabeledStatement", "WithStatement"], | ||||
|     }, | ||||
| 
 | ||||
|     "overrides": [ | ||||
|         { | ||||
|             "files": "test/**", | ||||
|             "rules": { | ||||
|                 "function-paren-newline": 0, | ||||
|                 "max-lines-per-function": 0, | ||||
|                 "max-statements": 0, | ||||
|                 "no-buffer-constructor": 0, | ||||
|                 "no-extend-native": 0, | ||||
|                 "no-throw-literal": 0, | ||||
|             }, | ||||
|         }, | ||||
|     ], | ||||
| } | ||||
							
								
								
									
										12
									
								
								node_modules/superagent/node_modules/qs/.github/FUNDING.yml
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								node_modules/superagent/node_modules/qs/.github/FUNDING.yml
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,12 @@ | |||
| # These are supported funding model platforms | ||||
| 
 | ||||
| github: [ljharb] | ||||
| patreon: # Replace with a single Patreon username | ||||
| open_collective: # Replace with a single Open Collective username | ||||
| ko_fi: # Replace with a single Ko-fi username | ||||
| tidelift: npm/qs | ||||
| community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry | ||||
| liberapay: # Replace with a single Liberapay username | ||||
| issuehunt: # Replace with a single IssueHunt username | ||||
| otechie: # Replace with a single Otechie username | ||||
| custom: # Replace with a single custom sponsorship URL | ||||
							
								
								
									
										13
									
								
								node_modules/superagent/node_modules/qs/.nycrc
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								node_modules/superagent/node_modules/qs/.nycrc
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| { | ||||
| 	"all": true, | ||||
| 	"check-coverage": false, | ||||
| 	"reporter": ["text-summary", "text", "html", "json"], | ||||
| 	"lines": 86, | ||||
| 	"statements": 85.93, | ||||
| 	"functions": 82.43, | ||||
| 	"branches": 76.06, | ||||
| 	"exclude": [ | ||||
| 		"coverage", | ||||
| 		"dist" | ||||
| 	] | ||||
| } | ||||
							
								
								
									
										546
									
								
								node_modules/superagent/node_modules/qs/CHANGELOG.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										546
									
								
								node_modules/superagent/node_modules/qs/CHANGELOG.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,546 @@ | |||
| ## **6.11.0 | ||||
| - [New] [Fix] `stringify`: revert 0e903c0; add `commaRoundTrip` option (#442) | ||||
| - [readme] fix version badge | ||||
| 
 | ||||
| ## **6.10.5** | ||||
| - [Fix] `stringify`: with `arrayFormat: comma`, properly include an explicit `[]` on a single-item array (#434) | ||||
| 
 | ||||
| ## **6.10.4** | ||||
| - [Fix] `stringify`: with `arrayFormat: comma`, include an explicit `[]` on a single-item array (#441) | ||||
| - [meta] use `npmignore` to autogenerate an npmignore file | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-symbol`, `object-inspect`, `tape` | ||||
| 
 | ||||
| ## **6.10.3** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [actions] reuse common workflows | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `tape` | ||||
| 
 | ||||
| ## **6.10.2** | ||||
| - [Fix] `stringify`: actually fix cyclic references (#426) | ||||
| - [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424) | ||||
| - [readme] remove travis badge; add github actions/codecov badges; update URLs | ||||
| - [Docs] add note and links for coercing primitive values (#408) | ||||
| - [actions] update codecov uploader | ||||
| - [actions] update workflows | ||||
| - [Tests] clean up stringify tests slightly | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `object-inspect`, `safe-publish-latest`, `tape` | ||||
| 
 | ||||
| ## **6.10.1** | ||||
| - [Fix] `stringify`: avoid exception on repeated object values (#402) | ||||
| 
 | ||||
| ## **6.10.0** | ||||
| - [New] `stringify`: throw on cycles, instead of an infinite loop (#395, #394, #393) | ||||
| - [New] `parse`: add `allowSparse` option for collapsing arrays with missing indices (#312) | ||||
| - [meta] fix README.md (#399) | ||||
| - [meta] only run `npm run dist` in publish, not install | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-symbols`, `tape` | ||||
| - [Tests] fix tests on node v0.6 | ||||
| - [Tests] use `ljharb/actions/node/install` instead of `ljharb/actions/node/run` | ||||
| - [Tests] Revert "[meta] ignore eclint transitive audit warning" | ||||
| 
 | ||||
| ## **6.9.7** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424) | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [readme] remove travis badge; add github actions/codecov badges; update URLs | ||||
| - [Docs] add note and links for coercing primitive values (#408) | ||||
| - [Tests] clean up stringify tests slightly | ||||
| - [meta] fix README.md (#399) | ||||
| - Revert "[meta] ignore eclint transitive audit warning" | ||||
| - [actions] backport actions from main | ||||
| - [Dev Deps] backport updates from main | ||||
| 
 | ||||
| ## **6.9.6** | ||||
| - [Fix] restore `dist` dir; mistakenly removed in d4f6c32 | ||||
| 
 | ||||
| ## **6.9.5** | ||||
| - [Fix] `stringify`: do not encode parens for RFC1738 | ||||
| - [Fix] `stringify`: fix arrayFormat comma with empty array/objects (#350) | ||||
| - [Refactor] `format`: remove `util.assign` call | ||||
| - [meta] add "Allow Edits" workflow; update rebase workflow | ||||
| - [actions] switch Automatic Rebase workflow to `pull_request_target` event | ||||
| - [Tests] `stringify`: add tests for #378 | ||||
| - [Tests] migrate tests to Github Actions | ||||
| - [Tests] run `nyc` on all tests; use `tape` runner | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `mkdirp`, `object-inspect`, `tape`; add `aud` | ||||
| 
 | ||||
| ## **6.9.4** | ||||
| - [Fix] `stringify`: when `arrayFormat` is `comma`, respect `serializeDate` (#364) | ||||
| - [Refactor] `stringify`: reduce branching (part of #350) | ||||
| - [Refactor] move `maybeMap` to `utils` | ||||
| - [Dev Deps] update `browserify`, `tape` | ||||
| 
 | ||||
| ## **6.9.3** | ||||
| - [Fix] proper comma parsing of URL-encoded commas (#361) | ||||
| - [Fix] parses comma delimited array while having percent-encoded comma treated as normal text (#336) | ||||
| 
 | ||||
| ## **6.9.2** | ||||
| - [Fix] `parse`: Fix parsing array from object with `comma` true (#359) | ||||
| - [Fix] `parse`: throw a TypeError instead of an Error for bad charset (#349) | ||||
| - [meta] ignore eclint transitive audit warning | ||||
| - [meta] fix indentation in package.json | ||||
| - [meta] add tidelift marketing copy | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `object-inspect`, `has-symbols`, `tape`, `mkdirp`, `iconv-lite` | ||||
| - [actions] add automatic rebasing / merge commit blocking | ||||
| 
 | ||||
| ## **6.9.1** | ||||
| - [Fix] `parse`: with comma true, handle field that holds an array of arrays (#335) | ||||
| - [Fix] `parse`: with comma true, do not split non-string values (#334) | ||||
| - [meta] add `funding` field | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config` | ||||
| - [Tests] use shared travis-ci config | ||||
| 
 | ||||
| ## **6.9.0** | ||||
| - [New] `parse`/`stringify`: Pass extra key/value argument to `decoder` (#333) | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `evalmd` | ||||
| - [Tests] `parse`: add passing `arrayFormat` tests | ||||
| - [Tests] add `posttest` using `npx aud` to run `npm audit` without a lockfile | ||||
| - [Tests] up to `node` `v12.10`, `v11.15`, `v10.16`, `v8.16` | ||||
| - [Tests] `Buffer.from` in node v5.0-v5.9 and v4.0-v4.4 requires a TypedArray | ||||
| 
 | ||||
| ## **6.8.3** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424) | ||||
| - [readme] remove travis badge; add github actions/codecov badges; update URLs | ||||
| - [Tests] clean up stringify tests slightly | ||||
| - [Docs] add note and links for coercing primitive values (#408) | ||||
| - [meta] fix README.md (#399) | ||||
| - [actions] backport actions from main | ||||
| - [Dev Deps] backport updates from main | ||||
| - [Refactor] `stringify`: reduce branching | ||||
| - [meta] do not publish workflow files | ||||
| 
 | ||||
| ## **6.8.2** | ||||
| - [Fix] proper comma parsing of URL-encoded commas (#361) | ||||
| - [Fix] parses comma delimited array while having percent-encoded comma treated as normal text (#336) | ||||
| 
 | ||||
| ## **6.8.1** | ||||
| - [Fix] `parse`: Fix parsing array from object with `comma` true (#359) | ||||
| - [Fix] `parse`: throw a TypeError instead of an Error for bad charset (#349) | ||||
| - [Fix] `parse`: with comma true, handle field that holds an array of arrays (#335) | ||||
| - [fix] `parse`: with comma true, do not split non-string values (#334) | ||||
| - [meta] add tidelift marketing copy | ||||
| - [meta] add `funding` field | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `safe-publish-latest`, `evalmd`, `has-symbols`, `iconv-lite`, `mkdirp`, `object-inspect` | ||||
| - [Tests] `parse`: add passing `arrayFormat` tests | ||||
| - [Tests] use shared travis-ci configs | ||||
| - [Tests] `Buffer.from` in node v5.0-v5.9 and v4.0-v4.4 requires a TypedArray | ||||
| - [actions] add automatic rebasing / merge commit blocking | ||||
| 
 | ||||
| ## **6.8.0** | ||||
| - [New] add `depth=false` to preserve the original key; [Fix] `depth=0` should preserve the original key (#326) | ||||
| - [New] [Fix] stringify symbols and bigints | ||||
| - [Fix] ensure node 0.12 can stringify Symbols | ||||
| - [Fix] fix for an impossible situation: when the formatter is called with a non-string value | ||||
| - [Refactor] `formats`: tiny bit of cleanup. | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `safe-publish-latest`, `iconv-lite`, `tape` | ||||
| - [Tests] add tests for `depth=0` and `depth=false` behavior, both current and intuitive/intended (#326) | ||||
| - [Tests] use `eclint` instead of `editorconfig-tools` | ||||
| - [docs] readme: add security note | ||||
| - [meta] add github sponsorship | ||||
| - [meta] add FUNDING.yml | ||||
| - [meta] Clean up license text so it’s properly detected as BSD-3-Clause | ||||
| 
 | ||||
| ## **6.7.3** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Fix] `stringify`: avoid encoding arrayformat comma when `encodeValuesOnly = true` (#424) | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [readme] remove travis badge; add github actions/codecov badges; update URLs | ||||
| - [Docs] add note and links for coercing primitive values (#408) | ||||
| - [meta] fix README.md (#399) | ||||
| - [meta] do not publish workflow files | ||||
| - [actions] backport actions from main | ||||
| - [Dev Deps] backport updates from main | ||||
| - [Tests] use `nyc` for coverage | ||||
| - [Tests] clean up stringify tests slightly | ||||
| 
 | ||||
| ## **6.7.2** | ||||
| - [Fix] proper comma parsing of URL-encoded commas (#361) | ||||
| - [Fix] parses comma delimited array while having percent-encoded comma treated as normal text (#336) | ||||
| 
 | ||||
| ## **6.7.1** | ||||
| - [Fix] `parse`: Fix parsing array from object with `comma` true (#359) | ||||
| - [Fix] `parse`: with comma true, handle field that holds an array of arrays (#335) | ||||
| - [fix] `parse`: with comma true, do not split non-string values (#334) | ||||
| - [Fix] `parse`: throw a TypeError instead of an Error for bad charset (#349) | ||||
| - [Fix] fix for an impossible situation: when the formatter is called with a non-string value | ||||
| - [Refactor] `formats`: tiny bit of cleanup. | ||||
| - readme: add security note | ||||
| - [meta] add tidelift marketing copy | ||||
| - [meta] add `funding` field | ||||
| - [meta] add FUNDING.yml | ||||
| - [meta] Clean up license text so it’s properly detected as BSD-3-Clause | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape`, `safe-publish-latest`, `evalmd`, `iconv-lite`, `mkdirp`, `object-inspect`, `browserify` | ||||
| - [Tests] `parse`: add passing `arrayFormat` tests | ||||
| - [Tests] use shared travis-ci configs | ||||
| - [Tests] `Buffer.from` in node v5.0-v5.9 and v4.0-v4.4 requires a TypedArray | ||||
| - [Tests] add tests for `depth=0` and `depth=false` behavior, both current and intuitive/intended | ||||
| - [Tests] use `eclint` instead of `editorconfig-tools` | ||||
| - [actions] add automatic rebasing / merge commit blocking | ||||
| 
 | ||||
| ## **6.7.0** | ||||
| - [New] `stringify`/`parse`: add `comma` as an `arrayFormat` option (#276, #219) | ||||
| - [Fix] correctly parse nested arrays (#212) | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and a truthy non-array source, also with an array source | ||||
| - [Robustness] `stringify`: cache `Object.prototype.hasOwnProperty` | ||||
| - [Refactor] `utils`: `isBuffer`: small tweak; add tests | ||||
| - [Refactor] use cached `Array.isArray` | ||||
| - [Refactor] `parse`/`stringify`: make a function to normalize the options | ||||
| - [Refactor] `utils`: reduce observable [[Get]]s | ||||
| - [Refactor] `stringify`/`utils`: cache `Array.isArray` | ||||
| - [Tests] always use `String(x)` over `x.toString()` | ||||
| - [Tests] fix Buffer tests to work in node < 4.5 and node < 5.10 | ||||
| - [Tests] temporarily allow coverage to fail | ||||
| 
 | ||||
| ## **6.6.1** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Fix] fix for an impossible situation: when the formatter is called with a non-string value | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and an array source | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and a truthy non-array source | ||||
| - [Fix] correctly parse nested arrays | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [Robustness] `stringify`: cache `Object.prototype.hasOwnProperty` | ||||
| - [Refactor] `formats`: tiny bit of cleanup. | ||||
| - [Refactor] `utils`: `isBuffer`: small tweak; add tests | ||||
| - [Refactor]: `stringify`/`utils`: cache `Array.isArray` | ||||
| - [Refactor] `utils`: reduce observable [[Get]]s | ||||
| - [Refactor] use cached `Array.isArray` | ||||
| - [Refactor] `parse`/`stringify`: make a function to normalize the options | ||||
| - [readme] remove travis badge; add github actions/codecov badges; update URLs | ||||
| - [Docs] Clarify the need for "arrayLimit" option | ||||
| - [meta] fix README.md (#399) | ||||
| - [meta] do not publish workflow files | ||||
| - [meta] Clean up license text so it’s properly detected as BSD-3-Clause | ||||
| - [meta] add FUNDING.yml | ||||
| - [meta] Fixes typo in CHANGELOG.md | ||||
| - [actions] backport actions from main | ||||
| - [Tests] fix Buffer tests to work in node < 4.5 and node < 5.10 | ||||
| - [Tests] always use `String(x)` over `x.toString()` | ||||
| - [Dev Deps] backport from main | ||||
| 
 | ||||
| ## **6.6.0** | ||||
| - [New] Add support for iso-8859-1, utf8 "sentinel" and numeric entities (#268) | ||||
| - [New] move two-value combine to a `utils` function (#189) | ||||
| - [Fix] `stringify`: fix a crash with `strictNullHandling` and a custom `filter`/`serializeDate` (#279) | ||||
| - [Fix] when `parseArrays` is false, properly handle keys ending in `[]` (#260) | ||||
| - [Fix] `stringify`: do not crash in an obscure combo of `interpretNumericEntities`, a bad custom `decoder`, & `iso-8859-1` | ||||
| - [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided | ||||
| - [refactor] `stringify`: Avoid arr = arr.concat(...), push to the existing instance (#269) | ||||
| - [Refactor] `parse`: only need to reassign the var once | ||||
| - [Refactor] `parse`/`stringify`: clean up `charset` options checking; fix defaults | ||||
| - [Refactor] add missing defaults | ||||
| - [Refactor] `parse`: one less `concat` call | ||||
| - [Refactor] `utils`: `compactQueue`: make it explicitly side-effecting | ||||
| - [Dev Deps] update `browserify`, `eslint`, `@ljharb/eslint-config`, `iconv-lite`, `safe-publish-latest`, `tape` | ||||
| - [Tests] up to `node` `v10.10`, `v9.11`, `v8.12`, `v6.14`, `v4.9`; pin included builds to LTS | ||||
| 
 | ||||
| ## **6.5.3** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Fix]` `utils.merge`: avoid a crash with a null target and a truthy non-array source | ||||
| - [Fix] correctly parse nested arrays | ||||
| - [Fix] `stringify`: fix a crash with `strictNullHandling` and a custom `filter`/`serializeDate` (#279) | ||||
| - [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided | ||||
| - [Fix] when `parseArrays` is false, properly handle keys ending in `[]` | ||||
| - [Fix] fix for an impossible situation: when the formatter is called with a non-string value | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and an array source | ||||
| - [Refactor] `utils`: reduce observable [[Get]]s | ||||
| - [Refactor] use cached `Array.isArray` | ||||
| - [Refactor] `stringify`: Avoid arr = arr.concat(...), push to the existing instance (#269) | ||||
| - [Refactor] `parse`: only need to reassign the var once | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [readme] remove travis badge; add github actions/codecov badges; update URLs | ||||
| - [Docs] Clean up license text so it’s properly detected as BSD-3-Clause | ||||
| - [Docs] Clarify the need for "arrayLimit" option | ||||
| - [meta] fix README.md (#399) | ||||
| - [meta] add FUNDING.yml | ||||
| - [actions] backport actions from main | ||||
| - [Tests] always use `String(x)` over `x.toString()` | ||||
| - [Tests] remove nonexistent tape option | ||||
| - [Dev Deps] backport from main | ||||
| 
 | ||||
| ## **6.5.2** | ||||
| - [Fix] use `safer-buffer` instead of `Buffer` constructor | ||||
| - [Refactor] utils: `module.exports` one thing, instead of mutating `exports` (#230) | ||||
| - [Dev Deps] update `browserify`, `eslint`, `iconv-lite`, `safer-buffer`, `tape`, `browserify` | ||||
| 
 | ||||
| ## **6.5.1** | ||||
| - [Fix] Fix parsing & compacting very deep objects (#224) | ||||
| - [Refactor] name utils functions | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` | ||||
| - [Tests] up to `node` `v8.4`; use `nvm install-latest-npm` so newer npm doesn’t break older node | ||||
| - [Tests] Use precise dist for Node.js 0.6 runtime (#225) | ||||
| - [Tests] make 0.6 required, now that it’s passing | ||||
| - [Tests] on `node` `v8.2`; fix npm on node 0.6 | ||||
| 
 | ||||
| ## **6.5.0** | ||||
| - [New] add `utils.assign` | ||||
| - [New] pass default encoder/decoder to custom encoder/decoder functions (#206) | ||||
| - [New] `parse`/`stringify`: add `ignoreQueryPrefix`/`addQueryPrefix` options, respectively (#213) | ||||
| - [Fix] Handle stringifying empty objects with addQueryPrefix (#217) | ||||
| - [Fix] do not mutate `options` argument (#207) | ||||
| - [Refactor] `parse`: cache index to reuse in else statement (#182) | ||||
| - [Docs] add various badges to readme (#208) | ||||
| - [Dev Deps] update `eslint`, `browserify`, `iconv-lite`, `tape` | ||||
| - [Tests] up to `node` `v8.1`, `v7.10`, `v6.11`; npm v4.6 breaks on node < v1; npm v5+ breaks on node < v4 | ||||
| - [Tests] add `editorconfig-tools` | ||||
| 
 | ||||
| ## **6.4.1** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Fix] fix for an impossible situation: when the formatter is called with a non-string value | ||||
| - [Fix] use `safer-buffer` instead of `Buffer` constructor | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and an array source | ||||
| - [Fix]` `utils.merge`: avoid a crash with a null target and a truthy non-array source | ||||
| - [Fix] `stringify`: fix a crash with `strictNullHandling` and a custom `filter`/`serializeDate` (#279) | ||||
| - [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided | ||||
| - [Fix] when `parseArrays` is false, properly handle keys ending in `[]` | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [Refactor] use cached `Array.isArray` | ||||
| - [Refactor] `stringify`: Avoid arr = arr.concat(...), push to the existing instance (#269) | ||||
| - [readme] remove travis badge; add github actions/codecov badges; update URLs | ||||
| - [Docs] Clarify the need for "arrayLimit" option | ||||
| - [meta] fix README.md (#399) | ||||
| - [meta] Clean up license text so it’s properly detected as BSD-3-Clause | ||||
| - [meta] add FUNDING.yml | ||||
| - [actions] backport actions from main | ||||
| - [Tests] remove nonexistent tape option | ||||
| - [Dev Deps] backport from main | ||||
| 
 | ||||
| ## **6.4.0** | ||||
| - [New] `qs.stringify`: add `encodeValuesOnly` option | ||||
| - [Fix] follow `allowPrototypes` option during merge (#201, #201) | ||||
| - [Fix] support keys starting with brackets (#202, #200) | ||||
| - [Fix] chmod a-x | ||||
| - [Dev Deps] update `eslint` | ||||
| - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds | ||||
| - [eslint] reduce warnings | ||||
| 
 | ||||
| ## **6.3.3** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Fix] fix for an impossible situation: when the formatter is called with a non-string value | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and an array source | ||||
| - [Fix]` `utils.merge`: avoid a crash with a null target and a truthy non-array source | ||||
| - [Fix] `stringify`: fix a crash with `strictNullHandling` and a custom `filter`/`serializeDate` (#279) | ||||
| - [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided | ||||
| - [Fix] when `parseArrays` is false, properly handle keys ending in `[]` | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [Refactor] use cached `Array.isArray` | ||||
| - [Refactor] `stringify`: Avoid arr = arr.concat(...), push to the existing instance (#269) | ||||
| - [Docs] Clarify the need for "arrayLimit" option | ||||
| - [meta] fix README.md (#399) | ||||
| - [meta] Clean up license text so it’s properly detected as BSD-3-Clause | ||||
| - [meta] add FUNDING.yml | ||||
| - [actions] backport actions from main | ||||
| - [Tests] use `safer-buffer` instead of `Buffer` constructor | ||||
| - [Tests] remove nonexistent tape option | ||||
| - [Dev Deps] backport from main | ||||
| 
 | ||||
| ## **6.3.2** | ||||
| - [Fix] follow `allowPrototypes` option during merge (#201, #200) | ||||
| - [Dev Deps] update `eslint` | ||||
| - [Fix] chmod a-x | ||||
| - [Fix] support keys starting with brackets (#202, #200) | ||||
| - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds | ||||
| 
 | ||||
| ## **6.3.1** | ||||
| - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties (thanks, @snyk!) | ||||
| - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `browserify`, `iconv-lite`, `qs-iconv`, `tape` | ||||
| - [Tests] on all node minors; improve test matrix | ||||
| - [Docs] document stringify option `allowDots` (#195) | ||||
| - [Docs] add empty object and array values example (#195) | ||||
| - [Docs] Fix minor inconsistency/typo (#192) | ||||
| - [Docs] document stringify option `sort` (#191) | ||||
| - [Refactor] `stringify`: throw faster with an invalid encoder | ||||
| - [Refactor] remove unnecessary escapes (#184) | ||||
| - Remove contributing.md, since `qs` is no longer part of `hapi` (#183) | ||||
| 
 | ||||
| ## **6.3.0** | ||||
| - [New] Add support for RFC 1738 (#174, #173) | ||||
| - [New] `stringify`: Add `serializeDate` option to customize Date serialization (#159) | ||||
| - [Fix] ensure `utils.merge` handles merging two arrays | ||||
| - [Refactor] only constructors should be capitalized | ||||
| - [Refactor] capitalized var names are for constructors only | ||||
| - [Refactor] avoid using a sparse array | ||||
| - [Robustness] `formats`: cache `String#replace` | ||||
| - [Dev Deps] update `browserify`, `eslint`, `@ljharb/eslint-config`; add `safe-publish-latest` | ||||
| - [Tests] up to `node` `v6.8`, `v4.6`; improve test matrix | ||||
| - [Tests] flesh out arrayLimit/arrayFormat tests (#107) | ||||
| - [Tests] skip Object.create tests when null objects are not available | ||||
| - [Tests] Turn on eslint for test files (#175) | ||||
| 
 | ||||
| ## **6.2.4** | ||||
| - [Fix] `parse`: ignore `__proto__` keys (#428) | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and an array source | ||||
| - [Fix] `utils.merge`: avoid a crash with a null target and a truthy non-array source | ||||
| - [Fix] `utils`: `merge`: fix crash when `source` is a truthy primitive & no options are provided | ||||
| - [Fix] when `parseArrays` is false, properly handle keys ending in `[]` | ||||
| - [Robustness] `stringify`: avoid relying on a global `undefined` (#427) | ||||
| - [Refactor] use cached `Array.isArray` | ||||
| - [Docs] Clarify the need for "arrayLimit" option | ||||
| - [meta] fix README.md (#399) | ||||
| - [meta] Clean up license text so it’s properly detected as BSD-3-Clause | ||||
| - [meta] add FUNDING.yml | ||||
| - [actions] backport actions from main | ||||
| - [Tests] use `safer-buffer` instead of `Buffer` constructor | ||||
| - [Tests] remove nonexistent tape option | ||||
| - [Dev Deps] backport from main | ||||
| 
 | ||||
| ## **6.2.3** | ||||
| - [Fix] follow `allowPrototypes` option during merge (#201, #200) | ||||
| - [Fix] chmod a-x | ||||
| - [Fix] support keys starting with brackets (#202, #200) | ||||
| - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds | ||||
| 
 | ||||
| ## **6.2.2** | ||||
| - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties | ||||
| 
 | ||||
| ## **6.2.1** | ||||
| - [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values | ||||
| - [Refactor] Be explicit and use `Object.prototype.hasOwnProperty.call` | ||||
| - [Tests] remove `parallelshell` since it does not reliably report failures | ||||
| - [Tests] up to `node` `v6.3`, `v5.12` | ||||
| - [Dev Deps] update `tape`, `eslint`, `@ljharb/eslint-config`, `qs-iconv` | ||||
| 
 | ||||
| ## [**6.2.0**](https://github.com/ljharb/qs/issues?milestone=36&state=closed) | ||||
| - [New] pass Buffers to the encoder/decoder directly (#161) | ||||
| - [New] add "encoder" and "decoder" options, for custom param encoding/decoding (#160) | ||||
| - [Fix] fix compacting of nested sparse arrays (#150) | ||||
| 
 | ||||
| ## **6.1.2 | ||||
| - [Fix] follow `allowPrototypes` option during merge (#201, #200) | ||||
| - [Fix] chmod a-x | ||||
| - [Fix] support keys starting with brackets (#202, #200) | ||||
| - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds | ||||
| 
 | ||||
| ## **6.1.1** | ||||
| - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties | ||||
| 
 | ||||
| ## [**6.1.0**](https://github.com/ljharb/qs/issues?milestone=35&state=closed) | ||||
| - [New] allowDots option for `stringify` (#151) | ||||
| - [Fix] "sort" option should work at a depth of 3 or more (#151) | ||||
| - [Fix] Restore `dist` directory; will be removed in v7 (#148) | ||||
| 
 | ||||
| ## **6.0.4** | ||||
| - [Fix] follow `allowPrototypes` option during merge (#201, #200) | ||||
| - [Fix] chmod a-x | ||||
| - [Fix] support keys starting with brackets (#202, #200) | ||||
| - [Tests] up to `node` `v7.7`, `v6.10`,` v4.8`; disable osx builds since they block linux builds | ||||
| 
 | ||||
| ## **6.0.3** | ||||
| - [Fix] ensure that `allowPrototypes: false` does not ever shadow Object.prototype properties | ||||
| - [Fix] Restore `dist` directory; will be removed in v7 (#148) | ||||
| 
 | ||||
| ## [**6.0.2**](https://github.com/ljharb/qs/issues?milestone=33&state=closed) | ||||
| - Revert ES6 requirement and restore support for node down to v0.8. | ||||
| 
 | ||||
| ## [**6.0.1**](https://github.com/ljharb/qs/issues?milestone=32&state=closed) | ||||
| - [**#127**](https://github.com/ljharb/qs/pull/127) Fix engines definition in package.json | ||||
| 
 | ||||
| ## [**6.0.0**](https://github.com/ljharb/qs/issues?milestone=31&state=closed) | ||||
| - [**#124**](https://github.com/ljharb/qs/issues/124) Use ES6 and drop support for node < v4 | ||||
| 
 | ||||
| ## **5.2.1** | ||||
| - [Fix] ensure `key[]=x&key[]&key[]=y` results in 3, not 2, values | ||||
| 
 | ||||
| ## [**5.2.0**](https://github.com/ljharb/qs/issues?milestone=30&state=closed) | ||||
| - [**#64**](https://github.com/ljharb/qs/issues/64) Add option to sort object keys in the query string | ||||
| 
 | ||||
| ## [**5.1.0**](https://github.com/ljharb/qs/issues?milestone=29&state=closed) | ||||
| - [**#117**](https://github.com/ljharb/qs/issues/117) make URI encoding stringified results optional | ||||
| - [**#106**](https://github.com/ljharb/qs/issues/106) Add flag `skipNulls` to optionally skip null values in stringify | ||||
| 
 | ||||
| ## [**5.0.0**](https://github.com/ljharb/qs/issues?milestone=28&state=closed) | ||||
| - [**#114**](https://github.com/ljharb/qs/issues/114) default allowDots to false | ||||
| - [**#100**](https://github.com/ljharb/qs/issues/100) include dist to npm | ||||
| 
 | ||||
| ## [**4.0.0**](https://github.com/ljharb/qs/issues?milestone=26&state=closed) | ||||
| - [**#98**](https://github.com/ljharb/qs/issues/98) make returning plain objects and allowing prototype overwriting properties optional | ||||
| 
 | ||||
| ## [**3.1.0**](https://github.com/ljharb/qs/issues?milestone=24&state=closed) | ||||
| - [**#89**](https://github.com/ljharb/qs/issues/89) Add option to disable "Transform dot notation to bracket notation" | ||||
| 
 | ||||
| ## [**3.0.0**](https://github.com/ljharb/qs/issues?milestone=23&state=closed) | ||||
| - [**#80**](https://github.com/ljharb/qs/issues/80) qs.parse silently drops properties | ||||
| - [**#77**](https://github.com/ljharb/qs/issues/77) Perf boost | ||||
| - [**#60**](https://github.com/ljharb/qs/issues/60) Add explicit option to disable array parsing | ||||
| - [**#74**](https://github.com/ljharb/qs/issues/74) Bad parse when turning array into object | ||||
| - [**#81**](https://github.com/ljharb/qs/issues/81) Add a `filter` option | ||||
| - [**#68**](https://github.com/ljharb/qs/issues/68) Fixed issue with recursion and passing strings into objects. | ||||
| - [**#66**](https://github.com/ljharb/qs/issues/66) Add mixed array and object dot notation support Closes: #47 | ||||
| - [**#76**](https://github.com/ljharb/qs/issues/76) RFC 3986 | ||||
| - [**#85**](https://github.com/ljharb/qs/issues/85) No equal sign | ||||
| - [**#84**](https://github.com/ljharb/qs/issues/84) update license attribute | ||||
| 
 | ||||
| ## [**2.4.1**](https://github.com/ljharb/qs/issues?milestone=20&state=closed) | ||||
| - [**#73**](https://github.com/ljharb/qs/issues/73) Property 'hasOwnProperty' of object #<Object> is not a function | ||||
| 
 | ||||
| ## [**2.4.0**](https://github.com/ljharb/qs/issues?milestone=19&state=closed) | ||||
| - [**#70**](https://github.com/ljharb/qs/issues/70) Add arrayFormat option | ||||
| 
 | ||||
| ## [**2.3.3**](https://github.com/ljharb/qs/issues?milestone=18&state=closed) | ||||
| - [**#59**](https://github.com/ljharb/qs/issues/59) make sure array indexes are >= 0, closes #57 | ||||
| - [**#58**](https://github.com/ljharb/qs/issues/58) make qs usable for browser loader | ||||
| 
 | ||||
| ## [**2.3.2**](https://github.com/ljharb/qs/issues?milestone=17&state=closed) | ||||
| - [**#55**](https://github.com/ljharb/qs/issues/55) allow merging a string into an object | ||||
| 
 | ||||
| ## [**2.3.1**](https://github.com/ljharb/qs/issues?milestone=16&state=closed) | ||||
| - [**#52**](https://github.com/ljharb/qs/issues/52) Return "undefined" and "false" instead of throwing "TypeError". | ||||
| 
 | ||||
| ## [**2.3.0**](https://github.com/ljharb/qs/issues?milestone=15&state=closed) | ||||
| - [**#50**](https://github.com/ljharb/qs/issues/50) add option to omit array indices, closes #46 | ||||
| 
 | ||||
| ## [**2.2.5**](https://github.com/ljharb/qs/issues?milestone=14&state=closed) | ||||
| - [**#39**](https://github.com/ljharb/qs/issues/39) Is there an alternative to Buffer.isBuffer? | ||||
| - [**#49**](https://github.com/ljharb/qs/issues/49) refactor utils.merge, fixes #45 | ||||
| - [**#41**](https://github.com/ljharb/qs/issues/41) avoid browserifying Buffer, for #39 | ||||
| 
 | ||||
| ## [**2.2.4**](https://github.com/ljharb/qs/issues?milestone=13&state=closed) | ||||
| - [**#38**](https://github.com/ljharb/qs/issues/38) how to handle object keys beginning with a number | ||||
| 
 | ||||
| ## [**2.2.3**](https://github.com/ljharb/qs/issues?milestone=12&state=closed) | ||||
| - [**#37**](https://github.com/ljharb/qs/issues/37) parser discards first empty value in array | ||||
| - [**#36**](https://github.com/ljharb/qs/issues/36) Update to lab 4.x | ||||
| 
 | ||||
| ## [**2.2.2**](https://github.com/ljharb/qs/issues?milestone=11&state=closed) | ||||
| - [**#33**](https://github.com/ljharb/qs/issues/33) Error when plain object in a value | ||||
| - [**#34**](https://github.com/ljharb/qs/issues/34) use Object.prototype.hasOwnProperty.call instead of obj.hasOwnProperty | ||||
| - [**#24**](https://github.com/ljharb/qs/issues/24) Changelog? Semver? | ||||
| 
 | ||||
| ## [**2.2.1**](https://github.com/ljharb/qs/issues?milestone=10&state=closed) | ||||
| - [**#32**](https://github.com/ljharb/qs/issues/32) account for circular references properly, closes #31 | ||||
| - [**#31**](https://github.com/ljharb/qs/issues/31) qs.parse stackoverflow on circular objects | ||||
| 
 | ||||
| ## [**2.2.0**](https://github.com/ljharb/qs/issues?milestone=9&state=closed) | ||||
| - [**#26**](https://github.com/ljharb/qs/issues/26) Don't use Buffer global if it's not present | ||||
| - [**#30**](https://github.com/ljharb/qs/issues/30) Bug when merging non-object values into arrays | ||||
| - [**#29**](https://github.com/ljharb/qs/issues/29) Don't call Utils.clone at the top of Utils.merge | ||||
| - [**#23**](https://github.com/ljharb/qs/issues/23) Ability to not limit parameters? | ||||
| 
 | ||||
| ## [**2.1.0**](https://github.com/ljharb/qs/issues?milestone=8&state=closed) | ||||
| - [**#22**](https://github.com/ljharb/qs/issues/22) Enable using a RegExp as delimiter | ||||
| 
 | ||||
| ## [**2.0.0**](https://github.com/ljharb/qs/issues?milestone=7&state=closed) | ||||
| - [**#18**](https://github.com/ljharb/qs/issues/18) Why is there arrayLimit? | ||||
| - [**#20**](https://github.com/ljharb/qs/issues/20) Configurable parametersLimit | ||||
| - [**#21**](https://github.com/ljharb/qs/issues/21) make all limits optional, for #18, for #20 | ||||
| 
 | ||||
| ## [**1.2.2**](https://github.com/ljharb/qs/issues?milestone=6&state=closed) | ||||
| - [**#19**](https://github.com/ljharb/qs/issues/19) Don't overwrite null values | ||||
| 
 | ||||
| ## [**1.2.1**](https://github.com/ljharb/qs/issues?milestone=5&state=closed) | ||||
| - [**#16**](https://github.com/ljharb/qs/issues/16) ignore non-string delimiters | ||||
| - [**#15**](https://github.com/ljharb/qs/issues/15) Close code block | ||||
| 
 | ||||
| ## [**1.2.0**](https://github.com/ljharb/qs/issues?milestone=4&state=closed) | ||||
| - [**#12**](https://github.com/ljharb/qs/issues/12) Add optional delim argument | ||||
| - [**#13**](https://github.com/ljharb/qs/issues/13) fix #11: flattened keys in array are now correctly parsed | ||||
| 
 | ||||
| ## [**1.1.0**](https://github.com/ljharb/qs/issues?milestone=3&state=closed) | ||||
| - [**#7**](https://github.com/ljharb/qs/issues/7) Empty values of a POST array disappear after being submitted | ||||
| - [**#9**](https://github.com/ljharb/qs/issues/9) Should not omit equals signs (=) when value is null | ||||
| - [**#6**](https://github.com/ljharb/qs/issues/6) Minor grammar fix in README | ||||
| 
 | ||||
| ## [**1.0.2**](https://github.com/ljharb/qs/issues?milestone=2&state=closed) | ||||
| - [**#5**](https://github.com/ljharb/qs/issues/5) array holes incorrectly copied into object on large index | ||||
							
								
								
									
										29
									
								
								node_modules/superagent/node_modules/qs/LICENSE.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								node_modules/superagent/node_modules/qs/LICENSE.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,29 @@ | |||
| BSD 3-Clause License | ||||
| 
 | ||||
| Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/ljharb/qs/graphs/contributors) | ||||
| All rights reserved. | ||||
| 
 | ||||
| Redistribution and use in source and binary forms, with or without | ||||
| modification, are permitted provided that the following conditions are met: | ||||
| 
 | ||||
| 1. Redistributions of source code must retain the above copyright notice, this | ||||
|    list of conditions and the following disclaimer. | ||||
| 
 | ||||
| 2. Redistributions in binary form must reproduce the above copyright notice, | ||||
|    this list of conditions and the following disclaimer in the documentation | ||||
|    and/or other materials provided with the distribution. | ||||
| 
 | ||||
| 3. Neither the name of the copyright holder nor the names of its | ||||
|    contributors may be used to endorse or promote products derived from | ||||
|    this software without specific prior written permission. | ||||
| 
 | ||||
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||||
| DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||||
| FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||||
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||||
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||||
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||||
| OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
							
								
								
									
										625
									
								
								node_modules/superagent/node_modules/qs/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										625
									
								
								node_modules/superagent/node_modules/qs/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,625 @@ | |||
| # qs <sup>[![Version Badge][npm-version-svg]][package-url]</sup> | ||||
| 
 | ||||
| [![github actions][actions-image]][actions-url] | ||||
| [![coverage][codecov-image]][codecov-url] | ||||
| [![dependency status][deps-svg]][deps-url] | ||||
| [![dev dependency status][dev-deps-svg]][dev-deps-url] | ||||
| [![License][license-image]][license-url] | ||||
| [![Downloads][downloads-image]][downloads-url] | ||||
| 
 | ||||
| [![npm badge][npm-badge-png]][package-url] | ||||
| 
 | ||||
| A querystring parsing and stringifying library with some added security. | ||||
| 
 | ||||
| Lead Maintainer: [Jordan Harband](https://github.com/ljharb) | ||||
| 
 | ||||
| The **qs** module was originally created and maintained by [TJ Holowaychuk](https://github.com/visionmedia/node-querystring). | ||||
| 
 | ||||
| ## Usage | ||||
| 
 | ||||
| ```javascript | ||||
| var qs = require('qs'); | ||||
| var assert = require('assert'); | ||||
| 
 | ||||
| var obj = qs.parse('a=c'); | ||||
| assert.deepEqual(obj, { a: 'c' }); | ||||
| 
 | ||||
| var str = qs.stringify(obj); | ||||
| assert.equal(str, 'a=c'); | ||||
| ``` | ||||
| 
 | ||||
| ### Parsing Objects | ||||
| 
 | ||||
| [](#preventEval) | ||||
| ```javascript | ||||
| qs.parse(string, [options]); | ||||
| ``` | ||||
| 
 | ||||
| **qs** allows you to create nested objects within your query strings, by surrounding the name of sub-keys with square brackets `[]`. | ||||
| For example, the string `'foo[bar]=baz'` converts to: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.deepEqual(qs.parse('foo[bar]=baz'), { | ||||
|     foo: { | ||||
|         bar: 'baz' | ||||
|     } | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| When using the `plainObjects` option the parsed value is returned as a null object, created via `Object.create(null)` and as such you should be aware that prototype methods will not exist on it and a user may set those names to whatever value they like: | ||||
| 
 | ||||
| ```javascript | ||||
| var nullObject = qs.parse('a[hasOwnProperty]=b', { plainObjects: true }); | ||||
| assert.deepEqual(nullObject, { a: { hasOwnProperty: 'b' } }); | ||||
| ``` | ||||
| 
 | ||||
| By default parameters that would overwrite properties on the object prototype are ignored, if you wish to keep the data from those fields either use `plainObjects` as mentioned above, or set `allowPrototypes` to `true` which will allow user input to overwrite those properties. *WARNING* It is generally a bad idea to enable this option as it can cause problems when attempting to use the properties that have been overwritten. Always be careful with this option. | ||||
| 
 | ||||
| ```javascript | ||||
| var protoObject = qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }); | ||||
| assert.deepEqual(protoObject, { a: { hasOwnProperty: 'b' } }); | ||||
| ``` | ||||
| 
 | ||||
| URI encoded strings work too: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.deepEqual(qs.parse('a%5Bb%5D=c'), { | ||||
|     a: { b: 'c' } | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| You can also nest your objects, like `'foo[bar][baz]=foobarbaz'`: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), { | ||||
|     foo: { | ||||
|         bar: { | ||||
|             baz: 'foobarbaz' | ||||
|         } | ||||
|     } | ||||
| }); | ||||
| ``` | ||||
| 
 | ||||
| By default, when nesting objects **qs** will only parse up to 5 children deep. This means if you attempt to parse a string like | ||||
| `'a[b][c][d][e][f][g][h][i]=j'` your resulting object will be: | ||||
| 
 | ||||
| ```javascript | ||||
| var expected = { | ||||
|     a: { | ||||
|         b: { | ||||
|             c: { | ||||
|                 d: { | ||||
|                     e: { | ||||
|                         f: { | ||||
|                             '[g][h][i]': 'j' | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| }; | ||||
| var string = 'a[b][c][d][e][f][g][h][i]=j'; | ||||
| assert.deepEqual(qs.parse(string), expected); | ||||
| ``` | ||||
| 
 | ||||
| This depth can be overridden by passing a `depth` option to `qs.parse(string, [options])`: | ||||
| 
 | ||||
| ```javascript | ||||
| var deep = qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 }); | ||||
| assert.deepEqual(deep, { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }); | ||||
| ``` | ||||
| 
 | ||||
| The depth limit helps mitigate abuse when **qs** is used to parse user input, and it is recommended to keep it a reasonably small number. | ||||
| 
 | ||||
| For similar reasons, by default **qs** will only parse up to 1000 parameters. This can be overridden by passing a `parameterLimit` option: | ||||
| 
 | ||||
| ```javascript | ||||
| var limited = qs.parse('a=b&c=d', { parameterLimit: 1 }); | ||||
| assert.deepEqual(limited, { a: 'b' }); | ||||
| ``` | ||||
| 
 | ||||
| To bypass the leading question mark, use `ignoreQueryPrefix`: | ||||
| 
 | ||||
| ```javascript | ||||
| var prefixed = qs.parse('?a=b&c=d', { ignoreQueryPrefix: true }); | ||||
| assert.deepEqual(prefixed, { a: 'b', c: 'd' }); | ||||
| ``` | ||||
| 
 | ||||
| An optional delimiter can also be passed: | ||||
| 
 | ||||
| ```javascript | ||||
| var delimited = qs.parse('a=b;c=d', { delimiter: ';' }); | ||||
| assert.deepEqual(delimited, { a: 'b', c: 'd' }); | ||||
| ``` | ||||
| 
 | ||||
| Delimiters can be a regular expression too: | ||||
| 
 | ||||
| ```javascript | ||||
| var regexed = qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ }); | ||||
| assert.deepEqual(regexed, { a: 'b', c: 'd', e: 'f' }); | ||||
| ``` | ||||
| 
 | ||||
| Option `allowDots` can be used to enable dot notation: | ||||
| 
 | ||||
| ```javascript | ||||
| var withDots = qs.parse('a.b=c', { allowDots: true }); | ||||
| assert.deepEqual(withDots, { a: { b: 'c' } }); | ||||
| ``` | ||||
| 
 | ||||
| If you have to deal with legacy browsers or services, there's | ||||
| also support for decoding percent-encoded octets as iso-8859-1: | ||||
| 
 | ||||
| ```javascript | ||||
| var oldCharset = qs.parse('a=%A7', { charset: 'iso-8859-1' }); | ||||
| assert.deepEqual(oldCharset, { a: '§' }); | ||||
| ``` | ||||
| 
 | ||||
| Some services add an initial `utf8=✓` value to forms so that old | ||||
| Internet Explorer versions are more likely to submit the form as | ||||
| utf-8. Additionally, the server can check the value against wrong | ||||
| encodings of the checkmark character and detect that a query string | ||||
| or `application/x-www-form-urlencoded` body was *not* sent as | ||||
| utf-8, eg. if the form had an `accept-charset` parameter or the | ||||
| containing page had a different character set. | ||||
| 
 | ||||
| **qs** supports this mechanism via the `charsetSentinel` option. | ||||
| If specified, the `utf8` parameter will be omitted from the | ||||
| returned object. It will be used to switch to `iso-8859-1`/`utf-8` | ||||
| mode depending on how the checkmark is encoded. | ||||
| 
 | ||||
| **Important**: When you specify both the `charset` option and the | ||||
| `charsetSentinel` option, the `charset` will be overridden when | ||||
| the request contains a `utf8` parameter from which the actual | ||||
| charset can be deduced. In that sense the `charset` will behave | ||||
| as the default charset rather than the authoritative charset. | ||||
| 
 | ||||
| ```javascript | ||||
| var detectedAsUtf8 = qs.parse('utf8=%E2%9C%93&a=%C3%B8', { | ||||
|     charset: 'iso-8859-1', | ||||
|     charsetSentinel: true | ||||
| }); | ||||
| assert.deepEqual(detectedAsUtf8, { a: 'ø' }); | ||||
| 
 | ||||
| // Browsers encode the checkmark as ✓ when submitting as iso-8859-1: | ||||
| var detectedAsIso8859_1 = qs.parse('utf8=%26%2310003%3B&a=%F8', { | ||||
|     charset: 'utf-8', | ||||
|     charsetSentinel: true | ||||
| }); | ||||
| assert.deepEqual(detectedAsIso8859_1, { a: 'ø' }); | ||||
| ``` | ||||
| 
 | ||||
| If you want to decode the `&#...;` syntax to the actual character, | ||||
| you can specify the `interpretNumericEntities` option as well: | ||||
| 
 | ||||
| ```javascript | ||||
| var detectedAsIso8859_1 = qs.parse('a=%26%239786%3B', { | ||||
|     charset: 'iso-8859-1', | ||||
|     interpretNumericEntities: true | ||||
| }); | ||||
| assert.deepEqual(detectedAsIso8859_1, { a: '☺' }); | ||||
| ``` | ||||
| 
 | ||||
| It also works when the charset has been detected in `charsetSentinel` | ||||
| mode. | ||||
| 
 | ||||
| ### Parsing Arrays | ||||
| 
 | ||||
| **qs** can also parse arrays using a similar `[]` notation: | ||||
| 
 | ||||
| ```javascript | ||||
| var withArray = qs.parse('a[]=b&a[]=c'); | ||||
| assert.deepEqual(withArray, { a: ['b', 'c'] }); | ||||
| ``` | ||||
| 
 | ||||
| You may specify an index as well: | ||||
| 
 | ||||
| ```javascript | ||||
| var withIndexes = qs.parse('a[1]=c&a[0]=b'); | ||||
| assert.deepEqual(withIndexes, { a: ['b', 'c'] }); | ||||
| ``` | ||||
| 
 | ||||
| Note that the only difference between an index in an array and a key in an object is that the value between the brackets must be a number | ||||
| to create an array. When creating arrays with specific indices, **qs** will compact a sparse array to only the existing values preserving | ||||
| their order: | ||||
| 
 | ||||
| ```javascript | ||||
| var noSparse = qs.parse('a[1]=b&a[15]=c'); | ||||
| assert.deepEqual(noSparse, { a: ['b', 'c'] }); | ||||
| ``` | ||||
| 
 | ||||
| You may also use `allowSparse` option to parse sparse arrays: | ||||
| 
 | ||||
| ```javascript | ||||
| var sparseArray = qs.parse('a[1]=2&a[3]=5', { allowSparse: true }); | ||||
| assert.deepEqual(sparseArray, { a: [, '2', , '5'] }); | ||||
| ``` | ||||
| 
 | ||||
| Note that an empty string is also a value, and will be preserved: | ||||
| 
 | ||||
| ```javascript | ||||
| var withEmptyString = qs.parse('a[]=&a[]=b'); | ||||
| assert.deepEqual(withEmptyString, { a: ['', 'b'] }); | ||||
| 
 | ||||
| var withIndexedEmptyString = qs.parse('a[0]=b&a[1]=&a[2]=c'); | ||||
| assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] }); | ||||
| ``` | ||||
| 
 | ||||
| **qs** will also limit specifying indices in an array to a maximum index of `20`. Any array members with an index of greater than `20` will | ||||
| instead be converted to an object with the index as the key. This is needed to handle cases when someone sent, for example, `a[999999999]` and it will take significant time to iterate over this huge array. | ||||
| 
 | ||||
| ```javascript | ||||
| var withMaxIndex = qs.parse('a[100]=b'); | ||||
| assert.deepEqual(withMaxIndex, { a: { '100': 'b' } }); | ||||
| ``` | ||||
| 
 | ||||
| This limit can be overridden by passing an `arrayLimit` option: | ||||
| 
 | ||||
| ```javascript | ||||
| var withArrayLimit = qs.parse('a[1]=b', { arrayLimit: 0 }); | ||||
| assert.deepEqual(withArrayLimit, { a: { '1': 'b' } }); | ||||
| ``` | ||||
| 
 | ||||
| To disable array parsing entirely, set `parseArrays` to `false`. | ||||
| 
 | ||||
| ```javascript | ||||
| var noParsingArrays = qs.parse('a[]=b', { parseArrays: false }); | ||||
| assert.deepEqual(noParsingArrays, { a: { '0': 'b' } }); | ||||
| ``` | ||||
| 
 | ||||
| If you mix notations, **qs** will merge the two items into an object: | ||||
| 
 | ||||
| ```javascript | ||||
| var mixedNotation = qs.parse('a[0]=b&a[b]=c'); | ||||
| assert.deepEqual(mixedNotation, { a: { '0': 'b', b: 'c' } }); | ||||
| ``` | ||||
| 
 | ||||
| You can also create arrays of objects: | ||||
| 
 | ||||
| ```javascript | ||||
| var arraysOfObjects = qs.parse('a[][b]=c'); | ||||
| assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] }); | ||||
| ``` | ||||
| 
 | ||||
| Some people use comma to join array, **qs** can parse it: | ||||
| ```javascript | ||||
| var arraysOfObjects = qs.parse('a=b,c', { comma: true }) | ||||
| assert.deepEqual(arraysOfObjects, { a: ['b', 'c'] }) | ||||
| ``` | ||||
| (_this cannot convert nested objects, such as `a={b:1},{c:d}`_) | ||||
| 
 | ||||
| ### Parsing primitive/scalar values (numbers, booleans, null, etc) | ||||
| 
 | ||||
| By default, all values are parsed as strings. This behavior will not change and is explained in [issue #91](https://github.com/ljharb/qs/issues/91). | ||||
| 
 | ||||
| ```javascript | ||||
| var primitiveValues = qs.parse('a=15&b=true&c=null'); | ||||
| assert.deepEqual(primitiveValues, { a: '15', b: 'true', c: 'null' }); | ||||
| ``` | ||||
| 
 | ||||
| If you wish to auto-convert values which look like numbers, booleans, and other values into their primitive counterparts, you can use the [query-types Express JS middleware](https://github.com/xpepermint/query-types) which will auto-convert all request query parameters. | ||||
| 
 | ||||
| ### Stringifying | ||||
| 
 | ||||
| [](#preventEval) | ||||
| ```javascript | ||||
| qs.stringify(object, [options]); | ||||
| ``` | ||||
| 
 | ||||
| When stringifying, **qs** by default URI encodes output. Objects are stringified as you would expect: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.equal(qs.stringify({ a: 'b' }), 'a=b'); | ||||
| assert.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); | ||||
| ``` | ||||
| 
 | ||||
| This encoding can be disabled by setting the `encode` option to `false`: | ||||
| 
 | ||||
| ```javascript | ||||
| var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false }); | ||||
| assert.equal(unencoded, 'a[b]=c'); | ||||
| ``` | ||||
| 
 | ||||
| Encoding can be disabled for keys by setting the `encodeValuesOnly` option to `true`: | ||||
| ```javascript | ||||
| var encodedValues = qs.stringify( | ||||
|     { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] }, | ||||
|     { encodeValuesOnly: true } | ||||
| ); | ||||
| assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h'); | ||||
| ``` | ||||
| 
 | ||||
| This encoding can also be replaced by a custom encoding method set as `encoder` option: | ||||
| 
 | ||||
| ```javascript | ||||
| var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) { | ||||
|     // Passed in values `a`, `b`, `c` | ||||
|     return // Return encoded string | ||||
| }}) | ||||
| ``` | ||||
| 
 | ||||
| _(Note: the `encoder` option does not apply if `encode` is `false`)_ | ||||
| 
 | ||||
| Analogue to the `encoder` there is a `decoder` option for `parse` to override decoding of properties and values: | ||||
| 
 | ||||
| ```javascript | ||||
| var decoded = qs.parse('x=z', { decoder: function (str) { | ||||
|     // Passed in values `x`, `z` | ||||
|     return // Return decoded string | ||||
| }}) | ||||
| ``` | ||||
| 
 | ||||
| You can encode keys and values using different logic by using the type argument provided to the encoder: | ||||
| 
 | ||||
| ```javascript | ||||
| var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str, defaultEncoder, charset, type) { | ||||
|     if (type === 'key') { | ||||
|         return // Encoded key | ||||
|     } else if (type === 'value') { | ||||
|         return // Encoded value | ||||
|     } | ||||
| }}) | ||||
| ``` | ||||
| 
 | ||||
| The type argument is also provided to the decoder: | ||||
| 
 | ||||
| ```javascript | ||||
| var decoded = qs.parse('x=z', { decoder: function (str, defaultDecoder, charset, type) { | ||||
|     if (type === 'key') { | ||||
|         return // Decoded key | ||||
|     } else if (type === 'value') { | ||||
|         return // Decoded value | ||||
|     } | ||||
| }}) | ||||
| ``` | ||||
| 
 | ||||
| Examples beyond this point will be shown as though the output is not URI encoded for clarity. Please note that the return values in these cases *will* be URI encoded during real usage. | ||||
| 
 | ||||
| When arrays are stringified, by default they are given explicit indices: | ||||
| 
 | ||||
| ```javascript | ||||
| qs.stringify({ a: ['b', 'c', 'd'] }); | ||||
| // 'a[0]=b&a[1]=c&a[2]=d' | ||||
| ``` | ||||
| 
 | ||||
| You may override this by setting the `indices` option to `false`: | ||||
| 
 | ||||
| ```javascript | ||||
| qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }); | ||||
| // 'a=b&a=c&a=d' | ||||
| ``` | ||||
| 
 | ||||
| You may use the `arrayFormat` option to specify the format of the output array: | ||||
| 
 | ||||
| ```javascript | ||||
| qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }) | ||||
| // 'a[0]=b&a[1]=c' | ||||
| qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }) | ||||
| // 'a[]=b&a[]=c' | ||||
| qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) | ||||
| // 'a=b&a=c' | ||||
| qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'comma' }) | ||||
| // 'a=b,c' | ||||
| ``` | ||||
| 
 | ||||
| Note: when using `arrayFormat` set to `'comma'`, you can also pass the `commaRoundTrip` option set to `true` or `false`, to append `[]` on single-item arrays, so that they can round trip through a parse. | ||||
| 
 | ||||
| When objects are stringified, by default they use bracket notation: | ||||
| 
 | ||||
| ```javascript | ||||
| qs.stringify({ a: { b: { c: 'd', e: 'f' } } }); | ||||
| // 'a[b][c]=d&a[b][e]=f' | ||||
| ``` | ||||
| 
 | ||||
| You may override this to use dot notation by setting the `allowDots` option to `true`: | ||||
| 
 | ||||
| ```javascript | ||||
| qs.stringify({ a: { b: { c: 'd', e: 'f' } } }, { allowDots: true }); | ||||
| // 'a.b.c=d&a.b.e=f' | ||||
| ``` | ||||
| 
 | ||||
| Empty strings and null values will omit the value, but the equals sign (=) remains in place: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.equal(qs.stringify({ a: '' }), 'a='); | ||||
| ``` | ||||
| 
 | ||||
| Key with no values (such as an empty object or array) will return nothing: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.equal(qs.stringify({ a: [] }), ''); | ||||
| assert.equal(qs.stringify({ a: {} }), ''); | ||||
| assert.equal(qs.stringify({ a: [{}] }), ''); | ||||
| assert.equal(qs.stringify({ a: { b: []} }), ''); | ||||
| assert.equal(qs.stringify({ a: { b: {}} }), ''); | ||||
| ``` | ||||
| 
 | ||||
| Properties that are set to `undefined` will be omitted entirely: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.equal(qs.stringify({ a: null, b: undefined }), 'a='); | ||||
| ``` | ||||
| 
 | ||||
| The query string may optionally be prepended with a question mark: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.equal(qs.stringify({ a: 'b', c: 'd' }, { addQueryPrefix: true }), '?a=b&c=d'); | ||||
| ``` | ||||
| 
 | ||||
| The delimiter may be overridden with stringify as well: | ||||
| 
 | ||||
| ```javascript | ||||
| assert.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d'); | ||||
| ``` | ||||
| 
 | ||||
| If you only want to override the serialization of `Date` objects, you can provide a `serializeDate` option: | ||||
| 
 | ||||
| ```javascript | ||||
| var date = new Date(7); | ||||
| assert.equal(qs.stringify({ a: date }), 'a=1970-01-01T00:00:00.007Z'.replace(/:/g, '%3A')); | ||||
| assert.equal( | ||||
|     qs.stringify({ a: date }, { serializeDate: function (d) { return d.getTime(); } }), | ||||
|     'a=7' | ||||
| ); | ||||
| ``` | ||||
| 
 | ||||
| You may use the `sort` option to affect the order of parameter keys: | ||||
| 
 | ||||
| ```javascript | ||||
| function alphabeticalSort(a, b) { | ||||
|     return a.localeCompare(b); | ||||
| } | ||||
| assert.equal(qs.stringify({ a: 'c', z: 'y', b : 'f' }, { sort: alphabeticalSort }), 'a=c&b=f&z=y'); | ||||
| ``` | ||||
| 
 | ||||
| Finally, you can use the `filter` option to restrict which keys will be included in the stringified output. | ||||
| If you pass a function, it will be called for each key to obtain the replacement value. Otherwise, if you | ||||
| pass an array, it will be used to select properties and array indices for stringification: | ||||
| 
 | ||||
| ```javascript | ||||
| function filterFunc(prefix, value) { | ||||
|     if (prefix == 'b') { | ||||
|         // Return an `undefined` value to omit a property. | ||||
|         return; | ||||
|     } | ||||
|     if (prefix == 'e[f]') { | ||||
|         return value.getTime(); | ||||
|     } | ||||
|     if (prefix == 'e[g][0]') { | ||||
|         return value * 2; | ||||
|     } | ||||
|     return value; | ||||
| } | ||||
| qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: filterFunc }); | ||||
| // 'a=b&c=d&e[f]=123&e[g][0]=4' | ||||
| qs.stringify({ a: 'b', c: 'd', e: 'f' }, { filter: ['a', 'e'] }); | ||||
| // 'a=b&e=f' | ||||
| qs.stringify({ a: ['b', 'c', 'd'], e: 'f' }, { filter: ['a', 0, 2] }); | ||||
| // 'a[0]=b&a[2]=d' | ||||
| ``` | ||||
| 
 | ||||
| ### Handling of `null` values | ||||
| 
 | ||||
| By default, `null` values are treated like empty strings: | ||||
| 
 | ||||
| ```javascript | ||||
| var withNull = qs.stringify({ a: null, b: '' }); | ||||
| assert.equal(withNull, 'a=&b='); | ||||
| ``` | ||||
| 
 | ||||
| Parsing does not distinguish between parameters with and without equal signs. Both are converted to empty strings. | ||||
| 
 | ||||
| ```javascript | ||||
| var equalsInsensitive = qs.parse('a&b='); | ||||
| assert.deepEqual(equalsInsensitive, { a: '', b: '' }); | ||||
| ``` | ||||
| 
 | ||||
| To distinguish between `null` values and empty strings use the `strictNullHandling` flag. In the result string the `null` | ||||
| values have no `=` sign: | ||||
| 
 | ||||
| ```javascript | ||||
| var strictNull = qs.stringify({ a: null, b: '' }, { strictNullHandling: true }); | ||||
| assert.equal(strictNull, 'a&b='); | ||||
| ``` | ||||
| 
 | ||||
| To parse values without `=` back to `null` use the `strictNullHandling` flag: | ||||
| 
 | ||||
| ```javascript | ||||
| var parsedStrictNull = qs.parse('a&b=', { strictNullHandling: true }); | ||||
| assert.deepEqual(parsedStrictNull, { a: null, b: '' }); | ||||
| ``` | ||||
| 
 | ||||
| To completely skip rendering keys with `null` values, use the `skipNulls` flag: | ||||
| 
 | ||||
| ```javascript | ||||
| var nullsSkipped = qs.stringify({ a: 'b', c: null}, { skipNulls: true }); | ||||
| assert.equal(nullsSkipped, 'a=b'); | ||||
| ``` | ||||
| 
 | ||||
| If you're communicating with legacy systems, you can switch to `iso-8859-1` | ||||
| using the `charset` option: | ||||
| 
 | ||||
| ```javascript | ||||
| var iso = qs.stringify({ æ: 'æ' }, { charset: 'iso-8859-1' }); | ||||
| assert.equal(iso, '%E6=%E6'); | ||||
| ``` | ||||
| 
 | ||||
| Characters that don't exist in `iso-8859-1` will be converted to numeric | ||||
| entities, similar to what browsers do: | ||||
| 
 | ||||
| ```javascript | ||||
| var numeric = qs.stringify({ a: '☺' }, { charset: 'iso-8859-1' }); | ||||
| assert.equal(numeric, 'a=%26%239786%3B'); | ||||
| ``` | ||||
| 
 | ||||
| You can use the `charsetSentinel` option to announce the character by | ||||
| including an `utf8=✓` parameter with the proper encoding if the checkmark, | ||||
| similar to what Ruby on Rails and others do when submitting forms. | ||||
| 
 | ||||
| ```javascript | ||||
| var sentinel = qs.stringify({ a: '☺' }, { charsetSentinel: true }); | ||||
| assert.equal(sentinel, 'utf8=%E2%9C%93&a=%E2%98%BA'); | ||||
| 
 | ||||
| var isoSentinel = qs.stringify({ a: 'æ' }, { charsetSentinel: true, charset: 'iso-8859-1' }); | ||||
| assert.equal(isoSentinel, 'utf8=%26%2310003%3B&a=%E6'); | ||||
| ``` | ||||
| 
 | ||||
| ### Dealing with special character sets | ||||
| 
 | ||||
| By default the encoding and decoding of characters is done in `utf-8`, | ||||
| and `iso-8859-1` support is also built in via the `charset` parameter. | ||||
| 
 | ||||
| If you wish to encode querystrings to a different character set (i.e. | ||||
| [Shift JIS](https://en.wikipedia.org/wiki/Shift_JIS)) you can use the | ||||
| [`qs-iconv`](https://github.com/martinheidegger/qs-iconv) library: | ||||
| 
 | ||||
| ```javascript | ||||
| var encoder = require('qs-iconv/encoder')('shift_jis'); | ||||
| var shiftJISEncoded = qs.stringify({ a: 'こんにちは!' }, { encoder: encoder }); | ||||
| assert.equal(shiftJISEncoded, 'a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I'); | ||||
| ``` | ||||
| 
 | ||||
| This also works for decoding of query strings: | ||||
| 
 | ||||
| ```javascript | ||||
| var decoder = require('qs-iconv/decoder')('shift_jis'); | ||||
| var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder }); | ||||
| assert.deepEqual(obj, { a: 'こんにちは!' }); | ||||
| ``` | ||||
| 
 | ||||
| ### RFC 3986 and RFC 1738 space encoding | ||||
| 
 | ||||
| RFC3986 used as default option and encodes ' ' to *%20* which is backward compatible. | ||||
| In the same time, output can be stringified as per RFC1738 with ' ' equal to '+'. | ||||
| 
 | ||||
| ``` | ||||
| assert.equal(qs.stringify({ a: 'b c' }), 'a=b%20c'); | ||||
| assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c'); | ||||
| assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c'); | ||||
| ``` | ||||
| 
 | ||||
| ## Security | ||||
| 
 | ||||
| Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report. | ||||
| 
 | ||||
| ## qs for enterprise | ||||
| 
 | ||||
| Available as part of the Tidelift Subscription | ||||
| 
 | ||||
| The maintainers of qs and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-qs?utm_source=npm-qs&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) | ||||
| 
 | ||||
| [package-url]: https://npmjs.org/package/qs | ||||
| [npm-version-svg]: https://versionbadg.es/ljharb/qs.svg | ||||
| [deps-svg]: https://david-dm.org/ljharb/qs.svg | ||||
| [deps-url]: https://david-dm.org/ljharb/qs | ||||
| [dev-deps-svg]: https://david-dm.org/ljharb/qs/dev-status.svg | ||||
| [dev-deps-url]: https://david-dm.org/ljharb/qs#info=devDependencies | ||||
| [npm-badge-png]: https://nodei.co/npm/qs.png?downloads=true&stars=true | ||||
| [license-image]: https://img.shields.io/npm/l/qs.svg | ||||
| [license-url]: LICENSE | ||||
| [downloads-image]: https://img.shields.io/npm/dm/qs.svg | ||||
| [downloads-url]: https://npm-stat.com/charts.html?package=qs | ||||
| [codecov-image]: https://codecov.io/gh/ljharb/qs/branch/main/graphs/badge.svg | ||||
| [codecov-url]: https://app.codecov.io/gh/ljharb/qs/ | ||||
| [actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/qs | ||||
| [actions-url]: https://github.com/ljharb/qs/actions | ||||
							
								
								
									
										2054
									
								
								node_modules/superagent/node_modules/qs/dist/qs.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2054
									
								
								node_modules/superagent/node_modules/qs/dist/qs.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										23
									
								
								node_modules/superagent/node_modules/qs/lib/formats.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								node_modules/superagent/node_modules/qs/lib/formats.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,23 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var replace = String.prototype.replace; | ||||
| var percentTwenties = /%20/g; | ||||
| 
 | ||||
| var Format = { | ||||
|     RFC1738: 'RFC1738', | ||||
|     RFC3986: 'RFC3986' | ||||
| }; | ||||
| 
 | ||||
| module.exports = { | ||||
|     'default': Format.RFC3986, | ||||
|     formatters: { | ||||
|         RFC1738: function (value) { | ||||
|             return replace.call(value, percentTwenties, '+'); | ||||
|         }, | ||||
|         RFC3986: function (value) { | ||||
|             return String(value); | ||||
|         } | ||||
|     }, | ||||
|     RFC1738: Format.RFC1738, | ||||
|     RFC3986: Format.RFC3986 | ||||
| }; | ||||
							
								
								
									
										11
									
								
								node_modules/superagent/node_modules/qs/lib/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								node_modules/superagent/node_modules/qs/lib/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var stringify = require('./stringify'); | ||||
| var parse = require('./parse'); | ||||
| var formats = require('./formats'); | ||||
| 
 | ||||
| module.exports = { | ||||
|     formats: formats, | ||||
|     parse: parse, | ||||
|     stringify: stringify | ||||
| }; | ||||
							
								
								
									
										263
									
								
								node_modules/superagent/node_modules/qs/lib/parse.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										263
									
								
								node_modules/superagent/node_modules/qs/lib/parse.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,263 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var utils = require('./utils'); | ||||
| 
 | ||||
| var has = Object.prototype.hasOwnProperty; | ||||
| var isArray = Array.isArray; | ||||
| 
 | ||||
| var defaults = { | ||||
|     allowDots: false, | ||||
|     allowPrototypes: false, | ||||
|     allowSparse: false, | ||||
|     arrayLimit: 20, | ||||
|     charset: 'utf-8', | ||||
|     charsetSentinel: false, | ||||
|     comma: false, | ||||
|     decoder: utils.decode, | ||||
|     delimiter: '&', | ||||
|     depth: 5, | ||||
|     ignoreQueryPrefix: false, | ||||
|     interpretNumericEntities: false, | ||||
|     parameterLimit: 1000, | ||||
|     parseArrays: true, | ||||
|     plainObjects: false, | ||||
|     strictNullHandling: false | ||||
| }; | ||||
| 
 | ||||
| var interpretNumericEntities = function (str) { | ||||
|     return str.replace(/&#(\d+);/g, function ($0, numberStr) { | ||||
|         return String.fromCharCode(parseInt(numberStr, 10)); | ||||
|     }); | ||||
| }; | ||||
| 
 | ||||
| var parseArrayValue = function (val, options) { | ||||
|     if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) { | ||||
|         return val.split(','); | ||||
|     } | ||||
| 
 | ||||
|     return val; | ||||
| }; | ||||
| 
 | ||||
| // This is what browsers will submit when the ✓ character occurs in an
 | ||||
| // application/x-www-form-urlencoded body and the encoding of the page containing
 | ||||
| // the form is iso-8859-1, or when the submitted form has an accept-charset
 | ||||
| // attribute of iso-8859-1. Presumably also with other charsets that do not contain
 | ||||
| // the ✓ character, such as us-ascii.
 | ||||
| var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓')
 | ||||
| 
 | ||||
| // These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded.
 | ||||
| var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓')
 | ||||
| 
 | ||||
| var parseValues = function parseQueryStringValues(str, options) { | ||||
|     var obj = {}; | ||||
|     var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; | ||||
|     var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; | ||||
|     var parts = cleanStr.split(options.delimiter, limit); | ||||
|     var skipIndex = -1; // Keep track of where the utf8 sentinel was found
 | ||||
|     var i; | ||||
| 
 | ||||
|     var charset = options.charset; | ||||
|     if (options.charsetSentinel) { | ||||
|         for (i = 0; i < parts.length; ++i) { | ||||
|             if (parts[i].indexOf('utf8=') === 0) { | ||||
|                 if (parts[i] === charsetSentinel) { | ||||
|                     charset = 'utf-8'; | ||||
|                 } else if (parts[i] === isoSentinel) { | ||||
|                     charset = 'iso-8859-1'; | ||||
|                 } | ||||
|                 skipIndex = i; | ||||
|                 i = parts.length; // The eslint settings do not allow break;
 | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     for (i = 0; i < parts.length; ++i) { | ||||
|         if (i === skipIndex) { | ||||
|             continue; | ||||
|         } | ||||
|         var part = parts[i]; | ||||
| 
 | ||||
|         var bracketEqualsPos = part.indexOf(']='); | ||||
|         var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; | ||||
| 
 | ||||
|         var key, val; | ||||
|         if (pos === -1) { | ||||
|             key = options.decoder(part, defaults.decoder, charset, 'key'); | ||||
|             val = options.strictNullHandling ? null : ''; | ||||
|         } else { | ||||
|             key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key'); | ||||
|             val = utils.maybeMap( | ||||
|                 parseArrayValue(part.slice(pos + 1), options), | ||||
|                 function (encodedVal) { | ||||
|                     return options.decoder(encodedVal, defaults.decoder, charset, 'value'); | ||||
|                 } | ||||
|             ); | ||||
|         } | ||||
| 
 | ||||
|         if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { | ||||
|             val = interpretNumericEntities(val); | ||||
|         } | ||||
| 
 | ||||
|         if (part.indexOf('[]=') > -1) { | ||||
|             val = isArray(val) ? [val] : val; | ||||
|         } | ||||
| 
 | ||||
|         if (has.call(obj, key)) { | ||||
|             obj[key] = utils.combine(obj[key], val); | ||||
|         } else { | ||||
|             obj[key] = val; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return obj; | ||||
| }; | ||||
| 
 | ||||
| var parseObject = function (chain, val, options, valuesParsed) { | ||||
|     var leaf = valuesParsed ? val : parseArrayValue(val, options); | ||||
| 
 | ||||
|     for (var i = chain.length - 1; i >= 0; --i) { | ||||
|         var obj; | ||||
|         var root = chain[i]; | ||||
| 
 | ||||
|         if (root === '[]' && options.parseArrays) { | ||||
|             obj = [].concat(leaf); | ||||
|         } else { | ||||
|             obj = options.plainObjects ? Object.create(null) : {}; | ||||
|             var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; | ||||
|             var index = parseInt(cleanRoot, 10); | ||||
|             if (!options.parseArrays && cleanRoot === '') { | ||||
|                 obj = { 0: leaf }; | ||||
|             } else if ( | ||||
|                 !isNaN(index) | ||||
|                 && root !== cleanRoot | ||||
|                 && String(index) === cleanRoot | ||||
|                 && index >= 0 | ||||
|                 && (options.parseArrays && index <= options.arrayLimit) | ||||
|             ) { | ||||
|                 obj = []; | ||||
|                 obj[index] = leaf; | ||||
|             } else if (cleanRoot !== '__proto__') { | ||||
|                 obj[cleanRoot] = leaf; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         leaf = obj; | ||||
|     } | ||||
| 
 | ||||
|     return leaf; | ||||
| }; | ||||
| 
 | ||||
| var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) { | ||||
|     if (!givenKey) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     // Transform dot notation to bracket notation
 | ||||
|     var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; | ||||
| 
 | ||||
|     // The regex chunks
 | ||||
| 
 | ||||
|     var brackets = /(\[[^[\]]*])/; | ||||
|     var child = /(\[[^[\]]*])/g; | ||||
| 
 | ||||
|     // Get the parent
 | ||||
| 
 | ||||
|     var segment = options.depth > 0 && brackets.exec(key); | ||||
|     var parent = segment ? key.slice(0, segment.index) : key; | ||||
| 
 | ||||
|     // Stash the parent if it exists
 | ||||
| 
 | ||||
|     var keys = []; | ||||
|     if (parent) { | ||||
|         // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties
 | ||||
|         if (!options.plainObjects && has.call(Object.prototype, parent)) { | ||||
|             if (!options.allowPrototypes) { | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         keys.push(parent); | ||||
|     } | ||||
| 
 | ||||
|     // Loop through children appending to the array until we hit depth
 | ||||
| 
 | ||||
|     var i = 0; | ||||
|     while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) { | ||||
|         i += 1; | ||||
|         if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { | ||||
|             if (!options.allowPrototypes) { | ||||
|                 return; | ||||
|             } | ||||
|         } | ||||
|         keys.push(segment[1]); | ||||
|     } | ||||
| 
 | ||||
|     // If there's a remainder, just add whatever is left
 | ||||
| 
 | ||||
|     if (segment) { | ||||
|         keys.push('[' + key.slice(segment.index) + ']'); | ||||
|     } | ||||
| 
 | ||||
|     return parseObject(keys, val, options, valuesParsed); | ||||
| }; | ||||
| 
 | ||||
| var normalizeParseOptions = function normalizeParseOptions(opts) { | ||||
|     if (!opts) { | ||||
|         return defaults; | ||||
|     } | ||||
| 
 | ||||
|     if (opts.decoder !== null && opts.decoder !== undefined && typeof opts.decoder !== 'function') { | ||||
|         throw new TypeError('Decoder has to be a function.'); | ||||
|     } | ||||
| 
 | ||||
|     if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { | ||||
|         throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); | ||||
|     } | ||||
|     var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; | ||||
| 
 | ||||
|     return { | ||||
|         allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, | ||||
|         allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, | ||||
|         allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse, | ||||
|         arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, | ||||
|         charset: charset, | ||||
|         charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, | ||||
|         comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, | ||||
|         decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, | ||||
|         delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, | ||||
|         // eslint-disable-next-line no-implicit-coercion, no-extra-parens
 | ||||
|         depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth, | ||||
|         ignoreQueryPrefix: opts.ignoreQueryPrefix === true, | ||||
|         interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, | ||||
|         parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, | ||||
|         parseArrays: opts.parseArrays !== false, | ||||
|         plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, | ||||
|         strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling | ||||
|     }; | ||||
| }; | ||||
| 
 | ||||
| module.exports = function (str, opts) { | ||||
|     var options = normalizeParseOptions(opts); | ||||
| 
 | ||||
|     if (str === '' || str === null || typeof str === 'undefined') { | ||||
|         return options.plainObjects ? Object.create(null) : {}; | ||||
|     } | ||||
| 
 | ||||
|     var tempObj = typeof str === 'string' ? parseValues(str, options) : str; | ||||
|     var obj = options.plainObjects ? Object.create(null) : {}; | ||||
| 
 | ||||
|     // Iterate over the keys and setup the new object
 | ||||
| 
 | ||||
|     var keys = Object.keys(tempObj); | ||||
|     for (var i = 0; i < keys.length; ++i) { | ||||
|         var key = keys[i]; | ||||
|         var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string'); | ||||
|         obj = utils.merge(obj, newObj, options); | ||||
|     } | ||||
| 
 | ||||
|     if (options.allowSparse === true) { | ||||
|         return obj; | ||||
|     } | ||||
| 
 | ||||
|     return utils.compact(obj); | ||||
| }; | ||||
							
								
								
									
										326
									
								
								node_modules/superagent/node_modules/qs/lib/stringify.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										326
									
								
								node_modules/superagent/node_modules/qs/lib/stringify.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,326 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var getSideChannel = require('side-channel'); | ||||
| var utils = require('./utils'); | ||||
| var formats = require('./formats'); | ||||
| var has = Object.prototype.hasOwnProperty; | ||||
| 
 | ||||
| var arrayPrefixGenerators = { | ||||
|     brackets: function brackets(prefix) { | ||||
|         return prefix + '[]'; | ||||
|     }, | ||||
|     comma: 'comma', | ||||
|     indices: function indices(prefix, key) { | ||||
|         return prefix + '[' + key + ']'; | ||||
|     }, | ||||
|     repeat: function repeat(prefix) { | ||||
|         return prefix; | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| var isArray = Array.isArray; | ||||
| var split = String.prototype.split; | ||||
| var push = Array.prototype.push; | ||||
| var pushToArray = function (arr, valueOrArray) { | ||||
|     push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); | ||||
| }; | ||||
| 
 | ||||
| var toISO = Date.prototype.toISOString; | ||||
| 
 | ||||
| var defaultFormat = formats['default']; | ||||
| var defaults = { | ||||
|     addQueryPrefix: false, | ||||
|     allowDots: false, | ||||
|     charset: 'utf-8', | ||||
|     charsetSentinel: false, | ||||
|     delimiter: '&', | ||||
|     encode: true, | ||||
|     encoder: utils.encode, | ||||
|     encodeValuesOnly: false, | ||||
|     format: defaultFormat, | ||||
|     formatter: formats.formatters[defaultFormat], | ||||
|     // deprecated
 | ||||
|     indices: false, | ||||
|     serializeDate: function serializeDate(date) { | ||||
|         return toISO.call(date); | ||||
|     }, | ||||
|     skipNulls: false, | ||||
|     strictNullHandling: false | ||||
| }; | ||||
| 
 | ||||
| var isNonNullishPrimitive = function isNonNullishPrimitive(v) { | ||||
|     return typeof v === 'string' | ||||
|         || typeof v === 'number' | ||||
|         || typeof v === 'boolean' | ||||
|         || typeof v === 'symbol' | ||||
|         || typeof v === 'bigint'; | ||||
| }; | ||||
| 
 | ||||
| var sentinel = {}; | ||||
| 
 | ||||
| var stringify = function stringify( | ||||
|     object, | ||||
|     prefix, | ||||
|     generateArrayPrefix, | ||||
|     commaRoundTrip, | ||||
|     strictNullHandling, | ||||
|     skipNulls, | ||||
|     encoder, | ||||
|     filter, | ||||
|     sort, | ||||
|     allowDots, | ||||
|     serializeDate, | ||||
|     format, | ||||
|     formatter, | ||||
|     encodeValuesOnly, | ||||
|     charset, | ||||
|     sideChannel | ||||
| ) { | ||||
|     var obj = object; | ||||
| 
 | ||||
|     var tmpSc = sideChannel; | ||||
|     var step = 0; | ||||
|     var findFlag = false; | ||||
|     while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) { | ||||
|         // Where object last appeared in the ref tree
 | ||||
|         var pos = tmpSc.get(object); | ||||
|         step += 1; | ||||
|         if (typeof pos !== 'undefined') { | ||||
|             if (pos === step) { | ||||
|                 throw new RangeError('Cyclic object value'); | ||||
|             } else { | ||||
|                 findFlag = true; // Break while
 | ||||
|             } | ||||
|         } | ||||
|         if (typeof tmpSc.get(sentinel) === 'undefined') { | ||||
|             step = 0; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     if (typeof filter === 'function') { | ||||
|         obj = filter(prefix, obj); | ||||
|     } else if (obj instanceof Date) { | ||||
|         obj = serializeDate(obj); | ||||
|     } else if (generateArrayPrefix === 'comma' && isArray(obj)) { | ||||
|         obj = utils.maybeMap(obj, function (value) { | ||||
|             if (value instanceof Date) { | ||||
|                 return serializeDate(value); | ||||
|             } | ||||
|             return value; | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     if (obj === null) { | ||||
|         if (strictNullHandling) { | ||||
|             return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix; | ||||
|         } | ||||
| 
 | ||||
|         obj = ''; | ||||
|     } | ||||
| 
 | ||||
|     if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) { | ||||
|         if (encoder) { | ||||
|             var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format); | ||||
|             if (generateArrayPrefix === 'comma' && encodeValuesOnly) { | ||||
|                 var valuesArray = split.call(String(obj), ','); | ||||
|                 var valuesJoined = ''; | ||||
|                 for (var i = 0; i < valuesArray.length; ++i) { | ||||
|                     valuesJoined += (i === 0 ? '' : ',') + formatter(encoder(valuesArray[i], defaults.encoder, charset, 'value', format)); | ||||
|                 } | ||||
|                 return [formatter(keyValue) + (commaRoundTrip && isArray(obj) && valuesArray.length === 1 ? '[]' : '') + '=' + valuesJoined]; | ||||
|             } | ||||
|             return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))]; | ||||
|         } | ||||
|         return [formatter(prefix) + '=' + formatter(String(obj))]; | ||||
|     } | ||||
| 
 | ||||
|     var values = []; | ||||
| 
 | ||||
|     if (typeof obj === 'undefined') { | ||||
|         return values; | ||||
|     } | ||||
| 
 | ||||
|     var objKeys; | ||||
|     if (generateArrayPrefix === 'comma' && isArray(obj)) { | ||||
|         // we need to join elements in
 | ||||
|         objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }]; | ||||
|     } else if (isArray(filter)) { | ||||
|         objKeys = filter; | ||||
|     } else { | ||||
|         var keys = Object.keys(obj); | ||||
|         objKeys = sort ? keys.sort(sort) : keys; | ||||
|     } | ||||
| 
 | ||||
|     var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? prefix + '[]' : prefix; | ||||
| 
 | ||||
|     for (var j = 0; j < objKeys.length; ++j) { | ||||
|         var key = objKeys[j]; | ||||
|         var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key]; | ||||
| 
 | ||||
|         if (skipNulls && value === null) { | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         var keyPrefix = isArray(obj) | ||||
|             ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, key) : adjustedPrefix | ||||
|             : adjustedPrefix + (allowDots ? '.' + key : '[' + key + ']'); | ||||
| 
 | ||||
|         sideChannel.set(object, step); | ||||
|         var valueSideChannel = getSideChannel(); | ||||
|         valueSideChannel.set(sentinel, sideChannel); | ||||
|         pushToArray(values, stringify( | ||||
|             value, | ||||
|             keyPrefix, | ||||
|             generateArrayPrefix, | ||||
|             commaRoundTrip, | ||||
|             strictNullHandling, | ||||
|             skipNulls, | ||||
|             encoder, | ||||
|             filter, | ||||
|             sort, | ||||
|             allowDots, | ||||
|             serializeDate, | ||||
|             format, | ||||
|             formatter, | ||||
|             encodeValuesOnly, | ||||
|             charset, | ||||
|             valueSideChannel | ||||
|         )); | ||||
|     } | ||||
| 
 | ||||
|     return values; | ||||
| }; | ||||
| 
 | ||||
| var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { | ||||
|     if (!opts) { | ||||
|         return defaults; | ||||
|     } | ||||
| 
 | ||||
|     if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') { | ||||
|         throw new TypeError('Encoder has to be a function.'); | ||||
|     } | ||||
| 
 | ||||
|     var charset = opts.charset || defaults.charset; | ||||
|     if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { | ||||
|         throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); | ||||
|     } | ||||
| 
 | ||||
|     var format = formats['default']; | ||||
|     if (typeof opts.format !== 'undefined') { | ||||
|         if (!has.call(formats.formatters, opts.format)) { | ||||
|             throw new TypeError('Unknown format option provided.'); | ||||
|         } | ||||
|         format = opts.format; | ||||
|     } | ||||
|     var formatter = formats.formatters[format]; | ||||
| 
 | ||||
|     var filter = defaults.filter; | ||||
|     if (typeof opts.filter === 'function' || isArray(opts.filter)) { | ||||
|         filter = opts.filter; | ||||
|     } | ||||
| 
 | ||||
|     return { | ||||
|         addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, | ||||
|         allowDots: typeof opts.allowDots === 'undefined' ? defaults.allowDots : !!opts.allowDots, | ||||
|         charset: charset, | ||||
|         charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, | ||||
|         delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, | ||||
|         encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, | ||||
|         encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, | ||||
|         encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, | ||||
|         filter: filter, | ||||
|         format: format, | ||||
|         formatter: formatter, | ||||
|         serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, | ||||
|         skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, | ||||
|         sort: typeof opts.sort === 'function' ? opts.sort : null, | ||||
|         strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling | ||||
|     }; | ||||
| }; | ||||
| 
 | ||||
| module.exports = function (object, opts) { | ||||
|     var obj = object; | ||||
|     var options = normalizeStringifyOptions(opts); | ||||
| 
 | ||||
|     var objKeys; | ||||
|     var filter; | ||||
| 
 | ||||
|     if (typeof options.filter === 'function') { | ||||
|         filter = options.filter; | ||||
|         obj = filter('', obj); | ||||
|     } else if (isArray(options.filter)) { | ||||
|         filter = options.filter; | ||||
|         objKeys = filter; | ||||
|     } | ||||
| 
 | ||||
|     var keys = []; | ||||
| 
 | ||||
|     if (typeof obj !== 'object' || obj === null) { | ||||
|         return ''; | ||||
|     } | ||||
| 
 | ||||
|     var arrayFormat; | ||||
|     if (opts && opts.arrayFormat in arrayPrefixGenerators) { | ||||
|         arrayFormat = opts.arrayFormat; | ||||
|     } else if (opts && 'indices' in opts) { | ||||
|         arrayFormat = opts.indices ? 'indices' : 'repeat'; | ||||
|     } else { | ||||
|         arrayFormat = 'indices'; | ||||
|     } | ||||
| 
 | ||||
|     var generateArrayPrefix = arrayPrefixGenerators[arrayFormat]; | ||||
|     if (opts && 'commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') { | ||||
|         throw new TypeError('`commaRoundTrip` must be a boolean, or absent'); | ||||
|     } | ||||
|     var commaRoundTrip = generateArrayPrefix === 'comma' && opts && opts.commaRoundTrip; | ||||
| 
 | ||||
|     if (!objKeys) { | ||||
|         objKeys = Object.keys(obj); | ||||
|     } | ||||
| 
 | ||||
|     if (options.sort) { | ||||
|         objKeys.sort(options.sort); | ||||
|     } | ||||
| 
 | ||||
|     var sideChannel = getSideChannel(); | ||||
|     for (var i = 0; i < objKeys.length; ++i) { | ||||
|         var key = objKeys[i]; | ||||
| 
 | ||||
|         if (options.skipNulls && obj[key] === null) { | ||||
|             continue; | ||||
|         } | ||||
|         pushToArray(keys, stringify( | ||||
|             obj[key], | ||||
|             key, | ||||
|             generateArrayPrefix, | ||||
|             commaRoundTrip, | ||||
|             options.strictNullHandling, | ||||
|             options.skipNulls, | ||||
|             options.encode ? options.encoder : null, | ||||
|             options.filter, | ||||
|             options.sort, | ||||
|             options.allowDots, | ||||
|             options.serializeDate, | ||||
|             options.format, | ||||
|             options.formatter, | ||||
|             options.encodeValuesOnly, | ||||
|             options.charset, | ||||
|             sideChannel | ||||
|         )); | ||||
|     } | ||||
| 
 | ||||
|     var joined = keys.join(options.delimiter); | ||||
|     var prefix = options.addQueryPrefix === true ? '?' : ''; | ||||
| 
 | ||||
|     if (options.charsetSentinel) { | ||||
|         if (options.charset === 'iso-8859-1') { | ||||
|             // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark
 | ||||
|             prefix += 'utf8=%26%2310003%3B&'; | ||||
|         } else { | ||||
|             // encodeURIComponent('✓')
 | ||||
|             prefix += 'utf8=%E2%9C%93&'; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return joined.length > 0 ? prefix + joined : ''; | ||||
| }; | ||||
							
								
								
									
										252
									
								
								node_modules/superagent/node_modules/qs/lib/utils.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										252
									
								
								node_modules/superagent/node_modules/qs/lib/utils.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,252 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var formats = require('./formats'); | ||||
| 
 | ||||
| var has = Object.prototype.hasOwnProperty; | ||||
| var isArray = Array.isArray; | ||||
| 
 | ||||
| var hexTable = (function () { | ||||
|     var array = []; | ||||
|     for (var i = 0; i < 256; ++i) { | ||||
|         array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); | ||||
|     } | ||||
| 
 | ||||
|     return array; | ||||
| }()); | ||||
| 
 | ||||
| var compactQueue = function compactQueue(queue) { | ||||
|     while (queue.length > 1) { | ||||
|         var item = queue.pop(); | ||||
|         var obj = item.obj[item.prop]; | ||||
| 
 | ||||
|         if (isArray(obj)) { | ||||
|             var compacted = []; | ||||
| 
 | ||||
|             for (var j = 0; j < obj.length; ++j) { | ||||
|                 if (typeof obj[j] !== 'undefined') { | ||||
|                     compacted.push(obj[j]); | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|             item.obj[item.prop] = compacted; | ||||
|         } | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| var arrayToObject = function arrayToObject(source, options) { | ||||
|     var obj = options && options.plainObjects ? Object.create(null) : {}; | ||||
|     for (var i = 0; i < source.length; ++i) { | ||||
|         if (typeof source[i] !== 'undefined') { | ||||
|             obj[i] = source[i]; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     return obj; | ||||
| }; | ||||
| 
 | ||||
| var merge = function merge(target, source, options) { | ||||
|     /* eslint no-param-reassign: 0 */ | ||||
|     if (!source) { | ||||
|         return target; | ||||
|     } | ||||
| 
 | ||||
|     if (typeof source !== 'object') { | ||||
|         if (isArray(target)) { | ||||
|             target.push(source); | ||||
|         } else if (target && typeof target === 'object') { | ||||
|             if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { | ||||
|                 target[source] = true; | ||||
|             } | ||||
|         } else { | ||||
|             return [target, source]; | ||||
|         } | ||||
| 
 | ||||
|         return target; | ||||
|     } | ||||
| 
 | ||||
|     if (!target || typeof target !== 'object') { | ||||
|         return [target].concat(source); | ||||
|     } | ||||
| 
 | ||||
|     var mergeTarget = target; | ||||
|     if (isArray(target) && !isArray(source)) { | ||||
|         mergeTarget = arrayToObject(target, options); | ||||
|     } | ||||
| 
 | ||||
|     if (isArray(target) && isArray(source)) { | ||||
|         source.forEach(function (item, i) { | ||||
|             if (has.call(target, i)) { | ||||
|                 var targetItem = target[i]; | ||||
|                 if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { | ||||
|                     target[i] = merge(targetItem, item, options); | ||||
|                 } else { | ||||
|                     target.push(item); | ||||
|                 } | ||||
|             } else { | ||||
|                 target[i] = item; | ||||
|             } | ||||
|         }); | ||||
|         return target; | ||||
|     } | ||||
| 
 | ||||
|     return Object.keys(source).reduce(function (acc, key) { | ||||
|         var value = source[key]; | ||||
| 
 | ||||
|         if (has.call(acc, key)) { | ||||
|             acc[key] = merge(acc[key], value, options); | ||||
|         } else { | ||||
|             acc[key] = value; | ||||
|         } | ||||
|         return acc; | ||||
|     }, mergeTarget); | ||||
| }; | ||||
| 
 | ||||
| var assign = function assignSingleSource(target, source) { | ||||
|     return Object.keys(source).reduce(function (acc, key) { | ||||
|         acc[key] = source[key]; | ||||
|         return acc; | ||||
|     }, target); | ||||
| }; | ||||
| 
 | ||||
| var decode = function (str, decoder, charset) { | ||||
|     var strWithoutPlus = str.replace(/\+/g, ' '); | ||||
|     if (charset === 'iso-8859-1') { | ||||
|         // unescape never throws, no try...catch needed:
 | ||||
|         return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); | ||||
|     } | ||||
|     // utf-8
 | ||||
|     try { | ||||
|         return decodeURIComponent(strWithoutPlus); | ||||
|     } catch (e) { | ||||
|         return strWithoutPlus; | ||||
|     } | ||||
| }; | ||||
| 
 | ||||
| var encode = function encode(str, defaultEncoder, charset, kind, format) { | ||||
|     // This code was originally written by Brian White (mscdex) for the io.js core querystring library.
 | ||||
|     // It has been adapted here for stricter adherence to RFC 3986
 | ||||
|     if (str.length === 0) { | ||||
|         return str; | ||||
|     } | ||||
| 
 | ||||
|     var string = str; | ||||
|     if (typeof str === 'symbol') { | ||||
|         string = Symbol.prototype.toString.call(str); | ||||
|     } else if (typeof str !== 'string') { | ||||
|         string = String(str); | ||||
|     } | ||||
| 
 | ||||
|     if (charset === 'iso-8859-1') { | ||||
|         return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { | ||||
|             return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; | ||||
|         }); | ||||
|     } | ||||
| 
 | ||||
|     var out = ''; | ||||
|     for (var i = 0; i < string.length; ++i) { | ||||
|         var c = string.charCodeAt(i); | ||||
| 
 | ||||
|         if ( | ||||
|             c === 0x2D // -
 | ||||
|             || c === 0x2E // .
 | ||||
|             || c === 0x5F // _
 | ||||
|             || c === 0x7E // ~
 | ||||
|             || (c >= 0x30 && c <= 0x39) // 0-9
 | ||||
|             || (c >= 0x41 && c <= 0x5A) // a-z
 | ||||
|             || (c >= 0x61 && c <= 0x7A) // A-Z
 | ||||
|             || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( )
 | ||||
|         ) { | ||||
|             out += string.charAt(i); | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         if (c < 0x80) { | ||||
|             out = out + hexTable[c]; | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         if (c < 0x800) { | ||||
|             out = out + (hexTable[0xC0 | (c >> 6)] + hexTable[0x80 | (c & 0x3F)]); | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         if (c < 0xD800 || c >= 0xE000) { | ||||
|             out = out + (hexTable[0xE0 | (c >> 12)] + hexTable[0x80 | ((c >> 6) & 0x3F)] + hexTable[0x80 | (c & 0x3F)]); | ||||
|             continue; | ||||
|         } | ||||
| 
 | ||||
|         i += 1; | ||||
|         c = 0x10000 + (((c & 0x3FF) << 10) | (string.charCodeAt(i) & 0x3FF)); | ||||
|         /* eslint operator-linebreak: [2, "before"] */ | ||||
|         out += hexTable[0xF0 | (c >> 18)] | ||||
|             + hexTable[0x80 | ((c >> 12) & 0x3F)] | ||||
|             + hexTable[0x80 | ((c >> 6) & 0x3F)] | ||||
|             + hexTable[0x80 | (c & 0x3F)]; | ||||
|     } | ||||
| 
 | ||||
|     return out; | ||||
| }; | ||||
| 
 | ||||
| var compact = function compact(value) { | ||||
|     var queue = [{ obj: { o: value }, prop: 'o' }]; | ||||
|     var refs = []; | ||||
| 
 | ||||
|     for (var i = 0; i < queue.length; ++i) { | ||||
|         var item = queue[i]; | ||||
|         var obj = item.obj[item.prop]; | ||||
| 
 | ||||
|         var keys = Object.keys(obj); | ||||
|         for (var j = 0; j < keys.length; ++j) { | ||||
|             var key = keys[j]; | ||||
|             var val = obj[key]; | ||||
|             if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { | ||||
|                 queue.push({ obj: obj, prop: key }); | ||||
|                 refs.push(val); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     compactQueue(queue); | ||||
| 
 | ||||
|     return value; | ||||
| }; | ||||
| 
 | ||||
| var isRegExp = function isRegExp(obj) { | ||||
|     return Object.prototype.toString.call(obj) === '[object RegExp]'; | ||||
| }; | ||||
| 
 | ||||
| var isBuffer = function isBuffer(obj) { | ||||
|     if (!obj || typeof obj !== 'object') { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); | ||||
| }; | ||||
| 
 | ||||
| var combine = function combine(a, b) { | ||||
|     return [].concat(a, b); | ||||
| }; | ||||
| 
 | ||||
| var maybeMap = function maybeMap(val, fn) { | ||||
|     if (isArray(val)) { | ||||
|         var mapped = []; | ||||
|         for (var i = 0; i < val.length; i += 1) { | ||||
|             mapped.push(fn(val[i])); | ||||
|         } | ||||
|         return mapped; | ||||
|     } | ||||
|     return fn(val); | ||||
| }; | ||||
| 
 | ||||
| module.exports = { | ||||
|     arrayToObject: arrayToObject, | ||||
|     assign: assign, | ||||
|     combine: combine, | ||||
|     compact: compact, | ||||
|     decode: decode, | ||||
|     encode: encode, | ||||
|     isBuffer: isBuffer, | ||||
|     isRegExp: isRegExp, | ||||
|     maybeMap: maybeMap, | ||||
|     merge: merge | ||||
| }; | ||||
							
								
								
									
										77
									
								
								node_modules/superagent/node_modules/qs/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								node_modules/superagent/node_modules/qs/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,77 @@ | |||
| { | ||||
|     "name": "qs", | ||||
|     "description": "A querystring parser that supports nesting and arrays, with a depth limit", | ||||
|     "homepage": "https://github.com/ljharb/qs", | ||||
|     "version": "6.11.0", | ||||
|     "repository": { | ||||
|         "type": "git", | ||||
|         "url": "https://github.com/ljharb/qs.git" | ||||
|     }, | ||||
|     "funding": { | ||||
|         "url": "https://github.com/sponsors/ljharb" | ||||
|     }, | ||||
|     "main": "lib/index.js", | ||||
|     "contributors": [ | ||||
|         { | ||||
|             "name": "Jordan Harband", | ||||
|             "email": "ljharb@gmail.com", | ||||
|             "url": "http://ljharb.codes" | ||||
|         } | ||||
|     ], | ||||
|     "keywords": [ | ||||
|         "querystring", | ||||
|         "qs", | ||||
|         "query", | ||||
|         "url", | ||||
|         "parse", | ||||
|         "stringify" | ||||
|     ], | ||||
|     "engines": { | ||||
|         "node": ">=0.6" | ||||
|     }, | ||||
|     "dependencies": { | ||||
|         "side-channel": "^1.0.4" | ||||
|     }, | ||||
|     "devDependencies": { | ||||
|         "@ljharb/eslint-config": "^21.0.0", | ||||
|         "aud": "^2.0.0", | ||||
|         "browserify": "^16.5.2", | ||||
|         "eclint": "^2.8.1", | ||||
|         "eslint": "=8.8.0", | ||||
|         "evalmd": "^0.0.19", | ||||
|         "for-each": "^0.3.3", | ||||
|         "has-symbols": "^1.0.3", | ||||
|         "iconv-lite": "^0.5.1", | ||||
|         "in-publish": "^2.0.1", | ||||
|         "mkdirp": "^0.5.5", | ||||
|         "npmignore": "^0.3.0", | ||||
|         "nyc": "^10.3.2", | ||||
|         "object-inspect": "^1.12.2", | ||||
|         "qs-iconv": "^1.0.4", | ||||
|         "safe-publish-latest": "^2.0.0", | ||||
|         "safer-buffer": "^2.1.2", | ||||
|         "tape": "^5.5.3" | ||||
|     }, | ||||
|     "scripts": { | ||||
|         "prepack": "npmignore --auto --commentLines=autogenerated", | ||||
|         "prepublishOnly": "safe-publish-latest && npm run dist", | ||||
|         "prepublish": "not-in-publish || npm run prepublishOnly", | ||||
|         "pretest": "npm run --silent readme && npm run --silent lint", | ||||
|         "test": "npm run tests-only", | ||||
|         "tests-only": "nyc tape 'test/**/*.js'", | ||||
|         "posttest": "aud --production", | ||||
|         "readme": "evalmd README.md", | ||||
|         "postlint": "eclint check $(git ls-files | xargs find 2> /dev/null | grep -vE 'node_modules|\\.git' | grep -v dist/)", | ||||
|         "lint": "eslint --ext=js,mjs .", | ||||
|         "dist": "mkdirp dist && browserify --standalone Qs lib/index.js > dist/qs.js" | ||||
|     }, | ||||
|     "license": "BSD-3-Clause", | ||||
|     "publishConfig": { | ||||
|         "ignore": [ | ||||
|             "!dist/*", | ||||
|             "bower.json", | ||||
|             "component.json", | ||||
|             ".github/workflows" | ||||
|         ] | ||||
|     } | ||||
| } | ||||
							
								
								
									
										855
									
								
								node_modules/superagent/node_modules/qs/test/parse.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										855
									
								
								node_modules/superagent/node_modules/qs/test/parse.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,855 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var test = require('tape'); | ||||
| var qs = require('../'); | ||||
| var utils = require('../lib/utils'); | ||||
| var iconv = require('iconv-lite'); | ||||
| var SaferBuffer = require('safer-buffer').Buffer; | ||||
| 
 | ||||
| test('parse()', function (t) { | ||||
|     t.test('parses a simple string', function (st) { | ||||
|         st.deepEqual(qs.parse('0=foo'), { 0: 'foo' }); | ||||
|         st.deepEqual(qs.parse('foo=c++'), { foo: 'c  ' }); | ||||
|         st.deepEqual(qs.parse('a[>=]=23'), { a: { '>=': '23' } }); | ||||
|         st.deepEqual(qs.parse('a[<=>]==23'), { a: { '<=>': '=23' } }); | ||||
|         st.deepEqual(qs.parse('a[==]=23'), { a: { '==': '23' } }); | ||||
|         st.deepEqual(qs.parse('foo', { strictNullHandling: true }), { foo: null }); | ||||
|         st.deepEqual(qs.parse('foo'), { foo: '' }); | ||||
|         st.deepEqual(qs.parse('foo='), { foo: '' }); | ||||
|         st.deepEqual(qs.parse('foo=bar'), { foo: 'bar' }); | ||||
|         st.deepEqual(qs.parse(' foo = bar = baz '), { ' foo ': ' bar = baz ' }); | ||||
|         st.deepEqual(qs.parse('foo=bar=baz'), { foo: 'bar=baz' }); | ||||
|         st.deepEqual(qs.parse('foo=bar&bar=baz'), { foo: 'bar', bar: 'baz' }); | ||||
|         st.deepEqual(qs.parse('foo2=bar2&baz2='), { foo2: 'bar2', baz2: '' }); | ||||
|         st.deepEqual(qs.parse('foo=bar&baz', { strictNullHandling: true }), { foo: 'bar', baz: null }); | ||||
|         st.deepEqual(qs.parse('foo=bar&baz'), { foo: 'bar', baz: '' }); | ||||
|         st.deepEqual(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'), { | ||||
|             cht: 'p3', | ||||
|             chd: 't:60,40', | ||||
|             chs: '250x100', | ||||
|             chl: 'Hello|World' | ||||
|         }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('arrayFormat: brackets allows only explicit arrays', function (st) { | ||||
|         st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'brackets' }), { a: 'b,c' }); | ||||
|         st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('arrayFormat: indices allows only indexed arrays', function (st) { | ||||
|         st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'indices' }), { a: 'b,c' }); | ||||
|         st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('arrayFormat: comma allows only comma-separated arrays', function (st) { | ||||
|         st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'comma' }), { a: 'b,c' }); | ||||
|         st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('arrayFormat: repeat allows only repeated values', function (st) { | ||||
|         st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'repeat' }), { a: 'b,c' }); | ||||
|         st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows enabling dot notation', function (st) { | ||||
|         st.deepEqual(qs.parse('a.b=c'), { 'a.b': 'c' }); | ||||
|         st.deepEqual(qs.parse('a.b=c', { allowDots: true }), { a: { b: 'c' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.deepEqual(qs.parse('a[b]=c'), { a: { b: 'c' } }, 'parses a single nested string'); | ||||
|     t.deepEqual(qs.parse('a[b][c]=d'), { a: { b: { c: 'd' } } }, 'parses a double nested string'); | ||||
|     t.deepEqual( | ||||
|         qs.parse('a[b][c][d][e][f][g][h]=i'), | ||||
|         { a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } }, | ||||
|         'defaults to a depth of 5' | ||||
|     ); | ||||
| 
 | ||||
|     t.test('only parses one level when depth = 1', function (st) { | ||||
|         st.deepEqual(qs.parse('a[b][c]=d', { depth: 1 }), { a: { b: { '[c]': 'd' } } }); | ||||
|         st.deepEqual(qs.parse('a[b][c][d]=e', { depth: 1 }), { a: { b: { '[c][d]': 'e' } } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses original key when depth = 0', function (st) { | ||||
|         st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: 0 }), { 'a[0]': 'b', 'a[1]': 'c' }); | ||||
|         st.deepEqual(qs.parse('a[0][0]=b&a[0][1]=c&a[1]=d&e=2', { depth: 0 }), { 'a[0][0]': 'b', 'a[0][1]': 'c', 'a[1]': 'd', e: '2' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses original key when depth = false', function (st) { | ||||
|         st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: false }), { 'a[0]': 'b', 'a[1]': 'c' }); | ||||
|         st.deepEqual(qs.parse('a[0][0]=b&a[0][1]=c&a[1]=d&e=2', { depth: false }), { 'a[0][0]': 'b', 'a[0][1]': 'c', 'a[1]': 'd', e: '2' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] }, 'parses a simple array'); | ||||
| 
 | ||||
|     t.test('parses an explicit array', function (st) { | ||||
|         st.deepEqual(qs.parse('a[]=b'), { a: ['b'] }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a[]=c'), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a[]=c&a[]=d'), { a: ['b', 'c', 'd'] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses a mix of simple and explicit arrays', function (st) { | ||||
|         st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[0]=b&a=c'), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a=b&a[0]=c'), { a: ['b', 'c'] }); | ||||
| 
 | ||||
|         st.deepEqual(qs.parse('a[1]=b&a=c', { arrayLimit: 20 }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a=c', { arrayLimit: 0 }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] }); | ||||
| 
 | ||||
|         st.deepEqual(qs.parse('a=b&a[1]=c', { arrayLimit: 20 }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a=b&a[]=c', { arrayLimit: 0 }), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses a nested array', function (st) { | ||||
|         st.deepEqual(qs.parse('a[b][]=c&a[b][]=d'), { a: { b: ['c', 'd'] } }); | ||||
|         st.deepEqual(qs.parse('a[>=]=25'), { a: { '>=': '25' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows to specify array indices', function (st) { | ||||
|         st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] }); | ||||
|         st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] }); | ||||
|         st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 20 }), { a: ['c'] }); | ||||
|         st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 0 }), { a: { 1: 'c' } }); | ||||
|         st.deepEqual(qs.parse('a[1]=c'), { a: ['c'] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('limits specific array indices to arrayLimit', function (st) { | ||||
|         st.deepEqual(qs.parse('a[20]=a', { arrayLimit: 20 }), { a: ['a'] }); | ||||
|         st.deepEqual(qs.parse('a[21]=a', { arrayLimit: 20 }), { a: { 21: 'a' } }); | ||||
| 
 | ||||
|         st.deepEqual(qs.parse('a[20]=a'), { a: ['a'] }); | ||||
|         st.deepEqual(qs.parse('a[21]=a'), { a: { 21: 'a' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.deepEqual(qs.parse('a[12b]=c'), { a: { '12b': 'c' } }, 'supports keys that begin with a number'); | ||||
| 
 | ||||
|     t.test('supports encoded = signs', function (st) { | ||||
|         st.deepEqual(qs.parse('he%3Dllo=th%3Dere'), { 'he=llo': 'th=ere' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('is ok with url encoded strings', function (st) { | ||||
|         st.deepEqual(qs.parse('a[b%20c]=d'), { a: { 'b c': 'd' } }); | ||||
|         st.deepEqual(qs.parse('a[b]=c%20d'), { a: { b: 'c d' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows brackets in the value', function (st) { | ||||
|         st.deepEqual(qs.parse('pets=["tobi"]'), { pets: '["tobi"]' }); | ||||
|         st.deepEqual(qs.parse('operators=[">=", "<="]'), { operators: '[">=", "<="]' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows empty values', function (st) { | ||||
|         st.deepEqual(qs.parse(''), {}); | ||||
|         st.deepEqual(qs.parse(null), {}); | ||||
|         st.deepEqual(qs.parse(undefined), {}); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('transforms arrays to objects', function (st) { | ||||
|         st.deepEqual(qs.parse('foo[0]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } }); | ||||
|         st.deepEqual(qs.parse('foo[bad]=baz&foo[0]=bar'), { foo: { bad: 'baz', 0: 'bar' } }); | ||||
|         st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar'), { foo: { bad: 'baz', 0: 'bar' } }); | ||||
|         st.deepEqual(qs.parse('foo[]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } }); | ||||
|         st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } }); | ||||
|         st.deepEqual(qs.parse('foo[0][a]=a&foo[0][b]=b&foo[1][a]=aa&foo[1][b]=bb'), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); | ||||
| 
 | ||||
|         st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', t: 'u' } }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { 0: 'b', t: 'u', hasOwnProperty: 'c' } }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', x: 'y' } }); | ||||
|         st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { 0: 'b', hasOwnProperty: 'c', x: 'y' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('transforms arrays to objects (dot notation)', function (st) { | ||||
|         st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: 'baz' } }); | ||||
|         st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad.boo=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } }); | ||||
|         st.deepEqual(qs.parse('foo[0][0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } }); | ||||
|         st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15'], bar: '2' }] }); | ||||
|         st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].baz[1]=16&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15', '16'], bar: '2' }] }); | ||||
|         st.deepEqual(qs.parse('foo.bad=baz&foo[0]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } }); | ||||
|         st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } }); | ||||
|         st.deepEqual(qs.parse('foo[]=bar&foo.bad=baz', { allowDots: true }), { foo: { 0: 'bar', bad: 'baz' } }); | ||||
|         st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } }); | ||||
|         st.deepEqual(qs.parse('foo[0].a=a&foo[0].b=b&foo[1].a=aa&foo[1].b=bb', { allowDots: true }), { foo: [{ a: 'a', b: 'b' }, { a: 'aa', b: 'bb' }] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('correctly prunes undefined values when converting an array to an object', function (st) { | ||||
|         st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('supports malformed uri characters', function (st) { | ||||
|         st.deepEqual(qs.parse('{%:%}', { strictNullHandling: true }), { '{%:%}': null }); | ||||
|         st.deepEqual(qs.parse('{%:%}='), { '{%:%}': '' }); | ||||
|         st.deepEqual(qs.parse('foo=%:%}'), { foo: '%:%}' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('doesn\'t produce empty keys', function (st) { | ||||
|         st.deepEqual(qs.parse('_r=1&'), { _r: '1' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('cannot access Object prototype', function (st) { | ||||
|         qs.parse('constructor[prototype][bad]=bad'); | ||||
|         qs.parse('bad[constructor][prototype][bad]=bad'); | ||||
|         st.equal(typeof Object.prototype.bad, 'undefined'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses arrays of objects', function (st) { | ||||
|         st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] }); | ||||
|         st.deepEqual(qs.parse('a[0][b]=c'), { a: [{ b: 'c' }] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows for empty strings in arrays', function (st) { | ||||
|         st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] }); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true, arrayLimit: 20 }), | ||||
|             { a: ['b', null, 'c', ''] }, | ||||
|             'with arrayLimit 20 + array indices: null then empty string works' | ||||
|         ); | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[]=b&a[]&a[]=c&a[]=', { strictNullHandling: true, arrayLimit: 0 }), | ||||
|             { a: ['b', null, 'c', ''] }, | ||||
|             'with arrayLimit 0 + array brackets: null then empty string works' | ||||
|         ); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true, arrayLimit: 20 }), | ||||
|             { a: ['b', '', 'c', null] }, | ||||
|             'with arrayLimit 20 + array indices: empty string then null works' | ||||
|         ); | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[]=b&a[]=&a[]=c&a[]', { strictNullHandling: true, arrayLimit: 0 }), | ||||
|             { a: ['b', '', 'c', null] }, | ||||
|             'with arrayLimit 0 + array brackets: empty string then null works' | ||||
|         ); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[]=&a[]=b&a[]=c'), | ||||
|             { a: ['', 'b', 'c'] }, | ||||
|             'array brackets: empty strings work' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('compacts sparse arrays', function (st) { | ||||
|         st.deepEqual(qs.parse('a[10]=1&a[2]=2', { arrayLimit: 20 }), { a: ['2', '1'] }); | ||||
|         st.deepEqual(qs.parse('a[1][b][2][c]=1', { arrayLimit: 20 }), { a: [{ b: [{ c: '1' }] }] }); | ||||
|         st.deepEqual(qs.parse('a[1][2][3][c]=1', { arrayLimit: 20 }), { a: [[[{ c: '1' }]]] }); | ||||
|         st.deepEqual(qs.parse('a[1][2][3][c][1]=1', { arrayLimit: 20 }), { a: [[[{ c: ['1'] }]]] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses sparse arrays', function (st) { | ||||
|         /* eslint no-sparse-arrays: 0 */ | ||||
|         st.deepEqual(qs.parse('a[4]=1&a[1]=2', { allowSparse: true }), { a: [, '2', , , '1'] }); | ||||
|         st.deepEqual(qs.parse('a[1][b][2][c]=1', { allowSparse: true }), { a: [, { b: [, , { c: '1' }] }] }); | ||||
|         st.deepEqual(qs.parse('a[1][2][3][c]=1', { allowSparse: true }), { a: [, [, , [, , , { c: '1' }]]] }); | ||||
|         st.deepEqual(qs.parse('a[1][2][3][c][1]=1', { allowSparse: true }), { a: [, [, , [, , , { c: [, '1'] }]]] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses semi-parsed strings', function (st) { | ||||
|         st.deepEqual(qs.parse({ 'a[b]': 'c' }), { a: { b: 'c' } }); | ||||
|         st.deepEqual(qs.parse({ 'a[b]': 'c', 'a[d]': 'e' }), { a: { b: 'c', d: 'e' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses buffers correctly', function (st) { | ||||
|         var b = SaferBuffer.from('test'); | ||||
|         st.deepEqual(qs.parse({ a: b }), { a: b }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses jquery-param strings', function (st) { | ||||
|         // readable = 'filter[0][]=int1&filter[0][]==&filter[0][]=77&filter[]=and&filter[2][]=int2&filter[2][]==&filter[2][]=8'
 | ||||
|         var encoded = 'filter%5B0%5D%5B%5D=int1&filter%5B0%5D%5B%5D=%3D&filter%5B0%5D%5B%5D=77&filter%5B%5D=and&filter%5B2%5D%5B%5D=int2&filter%5B2%5D%5B%5D=%3D&filter%5B2%5D%5B%5D=8'; | ||||
|         var expected = { filter: [['int1', '=', '77'], 'and', ['int2', '=', '8']] }; | ||||
|         st.deepEqual(qs.parse(encoded), expected); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('continues parsing when no parent is found', function (st) { | ||||
|         st.deepEqual(qs.parse('[]=&a=b'), { 0: '', a: 'b' }); | ||||
|         st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { 0: null, a: 'b' }); | ||||
|         st.deepEqual(qs.parse('[foo]=bar'), { foo: 'bar' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not error when parsing a very long array', function (st) { | ||||
|         var str = 'a[]=a'; | ||||
|         while (Buffer.byteLength(str) < 128 * 1024) { | ||||
|             str = str + '&' + str; | ||||
|         } | ||||
| 
 | ||||
|         st.doesNotThrow(function () { | ||||
|             qs.parse(str); | ||||
|         }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('should not throw when a native prototype has an enumerable property', function (st) { | ||||
|         Object.prototype.crash = ''; | ||||
|         Array.prototype.crash = ''; | ||||
|         st.doesNotThrow(qs.parse.bind(null, 'a=b')); | ||||
|         st.deepEqual(qs.parse('a=b'), { a: 'b' }); | ||||
|         st.doesNotThrow(qs.parse.bind(null, 'a[][b]=c')); | ||||
|         st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] }); | ||||
|         delete Object.prototype.crash; | ||||
|         delete Array.prototype.crash; | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses a string with an alternative string delimiter', function (st) { | ||||
|         st.deepEqual(qs.parse('a=b;c=d', { delimiter: ';' }), { a: 'b', c: 'd' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses a string with an alternative RegExp delimiter', function (st) { | ||||
|         st.deepEqual(qs.parse('a=b; c=d', { delimiter: /[;,] */ }), { a: 'b', c: 'd' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not use non-splittable objects as delimiters', function (st) { | ||||
|         st.deepEqual(qs.parse('a=b&c=d', { delimiter: true }), { a: 'b', c: 'd' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows overriding parameter limit', function (st) { | ||||
|         st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: 1 }), { a: 'b' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows setting the parameter limit to Infinity', function (st) { | ||||
|         st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: Infinity }), { a: 'b', c: 'd' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows overriding array limit', function (st) { | ||||
|         st.deepEqual(qs.parse('a[0]=b', { arrayLimit: -1 }), { a: { 0: 'b' } }); | ||||
|         st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: -1 }), { a: { '-1': 'b' } }); | ||||
|         st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 }), { a: { 0: 'b', 1: 'c' } }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows disabling array parsing', function (st) { | ||||
|         var indices = qs.parse('a[0]=b&a[1]=c', { parseArrays: false }); | ||||
|         st.deepEqual(indices, { a: { 0: 'b', 1: 'c' } }); | ||||
|         st.equal(Array.isArray(indices.a), false, 'parseArrays:false, indices case is not an array'); | ||||
| 
 | ||||
|         var emptyBrackets = qs.parse('a[]=b', { parseArrays: false }); | ||||
|         st.deepEqual(emptyBrackets, { a: { 0: 'b' } }); | ||||
|         st.equal(Array.isArray(emptyBrackets.a), false, 'parseArrays:false, empty brackets case is not an array'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows for query string prefix', function (st) { | ||||
|         st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' }); | ||||
|         st.deepEqual(qs.parse('foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' }); | ||||
|         st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: false }), { '?foo': 'bar' }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses an object', function (st) { | ||||
|         var input = { | ||||
|             'user[name]': { 'pop[bob]': 3 }, | ||||
|             'user[email]': null | ||||
|         }; | ||||
| 
 | ||||
|         var expected = { | ||||
|             user: { | ||||
|                 name: { 'pop[bob]': 3 }, | ||||
|                 email: null | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|         var result = qs.parse(input); | ||||
| 
 | ||||
|         st.deepEqual(result, expected); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses string with comma as array divider', function (st) { | ||||
|         st.deepEqual(qs.parse('foo=bar,tee', { comma: true }), { foo: ['bar', 'tee'] }); | ||||
|         st.deepEqual(qs.parse('foo[bar]=coffee,tee', { comma: true }), { foo: { bar: ['coffee', 'tee'] } }); | ||||
|         st.deepEqual(qs.parse('foo=', { comma: true }), { foo: '' }); | ||||
|         st.deepEqual(qs.parse('foo', { comma: true }), { foo: '' }); | ||||
|         st.deepEqual(qs.parse('foo', { comma: true, strictNullHandling: true }), { foo: null }); | ||||
| 
 | ||||
|         // test cases inversed from from stringify tests
 | ||||
|         st.deepEqual(qs.parse('a[0]=c'), { a: ['c'] }); | ||||
|         st.deepEqual(qs.parse('a[]=c'), { a: ['c'] }); | ||||
|         st.deepEqual(qs.parse('a[]=c', { comma: true }), { a: ['c'] }); | ||||
| 
 | ||||
|         st.deepEqual(qs.parse('a[0]=c&a[1]=d'), { a: ['c', 'd'] }); | ||||
|         st.deepEqual(qs.parse('a[]=c&a[]=d'), { a: ['c', 'd'] }); | ||||
|         st.deepEqual(qs.parse('a=c,d', { comma: true }), { a: ['c', 'd'] }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses values with comma as array divider', function (st) { | ||||
|         st.deepEqual(qs.parse({ foo: 'bar,tee' }, { comma: false }), { foo: 'bar,tee' }); | ||||
|         st.deepEqual(qs.parse({ foo: 'bar,tee' }, { comma: true }), { foo: ['bar', 'tee'] }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('use number decoder, parses string that has one number with comma option enabled', function (st) { | ||||
|         var decoder = function (str, defaultDecoder, charset, type) { | ||||
|             if (!isNaN(Number(str))) { | ||||
|                 return parseFloat(str); | ||||
|             } | ||||
|             return defaultDecoder(str, defaultDecoder, charset, type); | ||||
|         }; | ||||
| 
 | ||||
|         st.deepEqual(qs.parse('foo=1', { comma: true, decoder: decoder }), { foo: 1 }); | ||||
|         st.deepEqual(qs.parse('foo=0', { comma: true, decoder: decoder }), { foo: 0 }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses brackets holds array of arrays when having two parts of strings with comma as array divider', function (st) { | ||||
|         st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=4,5,6', { comma: true }), { foo: [['1', '2', '3'], ['4', '5', '6']] }); | ||||
|         st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=', { comma: true }), { foo: [['1', '2', '3'], ''] }); | ||||
|         st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=,', { comma: true }), { foo: [['1', '2', '3'], ['', '']] }); | ||||
|         st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=a', { comma: true }), { foo: [['1', '2', '3'], 'a'] }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses comma delimited array while having percent-encoded comma treated as normal text', function (st) { | ||||
|         st.deepEqual(qs.parse('foo=a%2Cb', { comma: true }), { foo: 'a,b' }); | ||||
|         st.deepEqual(qs.parse('foo=a%2C%20b,d', { comma: true }), { foo: ['a, b', 'd'] }); | ||||
|         st.deepEqual(qs.parse('foo=a%2C%20b,c%2C%20d', { comma: true }), { foo: ['a, b', 'c, d'] }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses an object in dot notation', function (st) { | ||||
|         var input = { | ||||
|             'user.name': { 'pop[bob]': 3 }, | ||||
|             'user.email.': null | ||||
|         }; | ||||
| 
 | ||||
|         var expected = { | ||||
|             user: { | ||||
|                 name: { 'pop[bob]': 3 }, | ||||
|                 email: null | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|         var result = qs.parse(input, { allowDots: true }); | ||||
| 
 | ||||
|         st.deepEqual(result, expected); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses an object and not child values', function (st) { | ||||
|         var input = { | ||||
|             'user[name]': { 'pop[bob]': { test: 3 } }, | ||||
|             'user[email]': null | ||||
|         }; | ||||
| 
 | ||||
|         var expected = { | ||||
|             user: { | ||||
|                 name: { 'pop[bob]': { test: 3 } }, | ||||
|                 email: null | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|         var result = qs.parse(input); | ||||
| 
 | ||||
|         st.deepEqual(result, expected); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not blow up when Buffer global is missing', function (st) { | ||||
|         var tempBuffer = global.Buffer; | ||||
|         delete global.Buffer; | ||||
|         var result = qs.parse('a=b&c=d'); | ||||
|         global.Buffer = tempBuffer; | ||||
|         st.deepEqual(result, { a: 'b', c: 'd' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not crash when parsing circular references', function (st) { | ||||
|         var a = {}; | ||||
|         a.b = a; | ||||
| 
 | ||||
|         var parsed; | ||||
| 
 | ||||
|         st.doesNotThrow(function () { | ||||
|             parsed = qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a }); | ||||
|         }); | ||||
| 
 | ||||
|         st.equal('foo' in parsed, true, 'parsed has "foo" property'); | ||||
|         st.equal('bar' in parsed.foo, true); | ||||
|         st.equal('baz' in parsed.foo, true); | ||||
|         st.equal(parsed.foo.bar, 'baz'); | ||||
|         st.deepEqual(parsed.foo.baz, a); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not crash when parsing deep objects', function (st) { | ||||
|         var parsed; | ||||
|         var str = 'foo'; | ||||
| 
 | ||||
|         for (var i = 0; i < 5000; i++) { | ||||
|             str += '[p]'; | ||||
|         } | ||||
| 
 | ||||
|         str += '=bar'; | ||||
| 
 | ||||
|         st.doesNotThrow(function () { | ||||
|             parsed = qs.parse(str, { depth: 5000 }); | ||||
|         }); | ||||
| 
 | ||||
|         st.equal('foo' in parsed, true, 'parsed has "foo" property'); | ||||
| 
 | ||||
|         var depth = 0; | ||||
|         var ref = parsed.foo; | ||||
|         while ((ref = ref.p)) { | ||||
|             depth += 1; | ||||
|         } | ||||
| 
 | ||||
|         st.equal(depth, 5000, 'parsed is 5000 properties deep'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses null objects correctly', { skip: !Object.create }, function (st) { | ||||
|         var a = Object.create(null); | ||||
|         a.b = 'c'; | ||||
| 
 | ||||
|         st.deepEqual(qs.parse(a), { b: 'c' }); | ||||
|         var result = qs.parse({ a: a }); | ||||
|         st.equal('a' in result, true, 'result has "a" property'); | ||||
|         st.deepEqual(result.a, a); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses dates correctly', function (st) { | ||||
|         var now = new Date(); | ||||
|         st.deepEqual(qs.parse({ a: now }), { a: now }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses regular expressions correctly', function (st) { | ||||
|         var re = /^test$/; | ||||
|         st.deepEqual(qs.parse({ a: re }), { a: re }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not allow overwriting prototype properties', function (st) { | ||||
|         st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: false }), {}); | ||||
|         st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: false }), {}); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('toString', { allowPrototypes: false }), | ||||
|             {}, | ||||
|             'bare "toString" results in {}' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can allow overwriting prototype properties', function (st) { | ||||
|         st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } }); | ||||
|         st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' }); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('toString', { allowPrototypes: true }), | ||||
|             { toString: '' }, | ||||
|             'bare "toString" results in { toString: "" }' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('params starting with a closing bracket', function (st) { | ||||
|         st.deepEqual(qs.parse(']=toString'), { ']': 'toString' }); | ||||
|         st.deepEqual(qs.parse(']]=toString'), { ']]': 'toString' }); | ||||
|         st.deepEqual(qs.parse(']hello]=toString'), { ']hello]': 'toString' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('params starting with a starting bracket', function (st) { | ||||
|         st.deepEqual(qs.parse('[=toString'), { '[': 'toString' }); | ||||
|         st.deepEqual(qs.parse('[[=toString'), { '[[': 'toString' }); | ||||
|         st.deepEqual(qs.parse('[hello[=toString'), { '[hello[': 'toString' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('add keys to objects', function (st) { | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[b]=c&a=d'), | ||||
|             { a: { b: 'c', d: true } }, | ||||
|             'can add keys to objects' | ||||
|         ); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[b]=c&a=toString'), | ||||
|             { a: { b: 'c' } }, | ||||
|             'can not overwrite prototype' | ||||
|         ); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[b]=c&a=toString', { allowPrototypes: true }), | ||||
|             { a: { b: 'c', toString: true } }, | ||||
|             'can overwrite prototype with allowPrototypes true' | ||||
|         ); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('a[b]=c&a=toString', { plainObjects: true }), | ||||
|             { __proto__: null, a: { __proto__: null, b: 'c', toString: true } }, | ||||
|             'can overwrite prototype with plainObjects true' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('dunder proto is ignored', function (st) { | ||||
|         var payload = 'categories[__proto__]=login&categories[__proto__]&categories[length]=42'; | ||||
|         var result = qs.parse(payload, { allowPrototypes: true }); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             result, | ||||
|             { | ||||
|                 categories: { | ||||
|                     length: '42' | ||||
|                 } | ||||
|             }, | ||||
|             'silent [[Prototype]] payload' | ||||
|         ); | ||||
| 
 | ||||
|         var plainResult = qs.parse(payload, { allowPrototypes: true, plainObjects: true }); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             plainResult, | ||||
|             { | ||||
|                 __proto__: null, | ||||
|                 categories: { | ||||
|                     __proto__: null, | ||||
|                     length: '42' | ||||
|                 } | ||||
|             }, | ||||
|             'silent [[Prototype]] payload: plain objects' | ||||
|         ); | ||||
| 
 | ||||
|         var query = qs.parse('categories[__proto__]=cats&categories[__proto__]=dogs&categories[some][json]=toInject', { allowPrototypes: true }); | ||||
| 
 | ||||
|         st.notOk(Array.isArray(query.categories), 'is not an array'); | ||||
|         st.notOk(query.categories instanceof Array, 'is not instanceof an array'); | ||||
|         st.deepEqual(query.categories, { some: { json: 'toInject' } }); | ||||
|         st.equal(JSON.stringify(query.categories), '{"some":{"json":"toInject"}}', 'stringifies as a non-array'); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('foo[__proto__][hidden]=value&foo[bar]=stuffs', { allowPrototypes: true }), | ||||
|             { | ||||
|                 foo: { | ||||
|                     bar: 'stuffs' | ||||
|                 } | ||||
|             }, | ||||
|             'hidden values' | ||||
|         ); | ||||
| 
 | ||||
|         st.deepEqual( | ||||
|             qs.parse('foo[__proto__][hidden]=value&foo[bar]=stuffs', { allowPrototypes: true, plainObjects: true }), | ||||
|             { | ||||
|                 __proto__: null, | ||||
|                 foo: { | ||||
|                     __proto__: null, | ||||
|                     bar: 'stuffs' | ||||
|                 } | ||||
|             }, | ||||
|             'hidden values: plain objects' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can return null objects', { skip: !Object.create }, function (st) { | ||||
|         var expected = Object.create(null); | ||||
|         expected.a = Object.create(null); | ||||
|         expected.a.b = 'c'; | ||||
|         expected.a.hasOwnProperty = 'd'; | ||||
|         st.deepEqual(qs.parse('a[b]=c&a[hasOwnProperty]=d', { plainObjects: true }), expected); | ||||
|         st.deepEqual(qs.parse(null, { plainObjects: true }), Object.create(null)); | ||||
|         var expectedArray = Object.create(null); | ||||
|         expectedArray.a = Object.create(null); | ||||
|         expectedArray.a[0] = 'b'; | ||||
|         expectedArray.a.c = 'd'; | ||||
|         st.deepEqual(qs.parse('a[]=b&a[c]=d', { plainObjects: true }), expectedArray); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can parse with custom encoding', function (st) { | ||||
|         st.deepEqual(qs.parse('%8c%a7=%91%e5%8d%e3%95%7b', { | ||||
|             decoder: function (str) { | ||||
|                 var reg = /%([0-9A-F]{2})/ig; | ||||
|                 var result = []; | ||||
|                 var parts = reg.exec(str); | ||||
|                 while (parts) { | ||||
|                     result.push(parseInt(parts[1], 16)); | ||||
|                     parts = reg.exec(str); | ||||
|                 } | ||||
|                 return String(iconv.decode(SaferBuffer.from(result), 'shift_jis')); | ||||
|             } | ||||
|         }), { 県: '大阪府' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('receives the default decoder as a second argument', function (st) { | ||||
|         st.plan(1); | ||||
|         qs.parse('a', { | ||||
|             decoder: function (str, defaultDecoder) { | ||||
|                 st.equal(defaultDecoder, utils.decode); | ||||
|             } | ||||
|         }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('throws error with wrong decoder', function (st) { | ||||
|         st['throws'](function () { | ||||
|             qs.parse({}, { decoder: 'string' }); | ||||
|         }, new TypeError('Decoder has to be a function.')); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not mutate the options argument', function (st) { | ||||
|         var options = {}; | ||||
|         qs.parse('a[b]=true', options); | ||||
|         st.deepEqual(options, {}); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('throws if an invalid charset is specified', function (st) { | ||||
|         st['throws'](function () { | ||||
|             qs.parse('a=b', { charset: 'foobar' }); | ||||
|         }, new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined')); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('parses an iso-8859-1 string if asked to', function (st) { | ||||
|         st.deepEqual(qs.parse('%A2=%BD', { charset: 'iso-8859-1' }), { '¢': '½' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     var urlEncodedCheckmarkInUtf8 = '%E2%9C%93'; | ||||
|     var urlEncodedOSlashInUtf8 = '%C3%B8'; | ||||
|     var urlEncodedNumCheckmark = '%26%2310003%3B'; | ||||
|     var urlEncodedNumSmiley = '%26%239786%3B'; | ||||
| 
 | ||||
|     t.test('prefers an utf-8 charset specified by the utf8 sentinel to a default charset of iso-8859-1', function (st) { | ||||
|         st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'iso-8859-1' }), { ø: 'ø' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('prefers an iso-8859-1 charset specified by the utf8 sentinel to a default charset of utf-8', function (st) { | ||||
|         st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { 'ø': 'ø' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not require the utf8 sentinel to be defined before the parameters whose decoding it affects', function (st) { | ||||
|         st.deepEqual(qs.parse('a=' + urlEncodedOSlashInUtf8 + '&utf8=' + urlEncodedNumCheckmark, { charsetSentinel: true, charset: 'utf-8' }), { a: 'ø' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('should ignore an utf8 sentinel with an unknown value', function (st) { | ||||
|         st.deepEqual(qs.parse('utf8=foo&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { ø: 'ø' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses the utf8 sentinel to switch to utf-8 when no default charset is given', function (st) { | ||||
|         st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { ø: 'ø' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses the utf8 sentinel to switch to iso-8859-1 when no default charset is given', function (st) { | ||||
|         st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { 'ø': 'ø' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('interprets numeric entities in iso-8859-1 when `interpretNumericEntities`', function (st) { | ||||
|         st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1', interpretNumericEntities: true }), { foo: '☺' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('handles a custom decoder returning `null`, in the `iso-8859-1` charset, when `interpretNumericEntities`', function (st) { | ||||
|         st.deepEqual(qs.parse('foo=&bar=' + urlEncodedNumSmiley, { | ||||
|             charset: 'iso-8859-1', | ||||
|             decoder: function (str, defaultDecoder, charset) { | ||||
|                 return str ? defaultDecoder(str, defaultDecoder, charset) : null; | ||||
|             }, | ||||
|             interpretNumericEntities: true | ||||
|         }), { foo: null, bar: '☺' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not interpret numeric entities in iso-8859-1 when `interpretNumericEntities` is absent', function (st) { | ||||
|         st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1' }), { foo: '☺' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not interpret numeric entities when the charset is utf-8, even when `interpretNumericEntities`', function (st) { | ||||
|         st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'utf-8', interpretNumericEntities: true }), { foo: '☺' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not interpret %uXXXX syntax in iso-8859-1 mode', function (st) { | ||||
|         st.deepEqual(qs.parse('%u263A=%u263A', { charset: 'iso-8859-1' }), { '%u263A': '%u263A' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows for decoding keys and values differently', function (st) { | ||||
|         var decoder = function (str, defaultDecoder, charset, type) { | ||||
|             if (type === 'key') { | ||||
|                 return defaultDecoder(str, defaultDecoder, charset, type).toLowerCase(); | ||||
|             } | ||||
|             if (type === 'value') { | ||||
|                 return defaultDecoder(str, defaultDecoder, charset, type).toUpperCase(); | ||||
|             } | ||||
|             throw 'this should never happen! type: ' + type; | ||||
|         }; | ||||
| 
 | ||||
|         st.deepEqual(qs.parse('KeY=vAlUe', { decoder: decoder }), { key: 'VALUE' }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.end(); | ||||
| }); | ||||
							
								
								
									
										909
									
								
								node_modules/superagent/node_modules/qs/test/stringify.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										909
									
								
								node_modules/superagent/node_modules/qs/test/stringify.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,909 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var test = require('tape'); | ||||
| var qs = require('../'); | ||||
| var utils = require('../lib/utils'); | ||||
| var iconv = require('iconv-lite'); | ||||
| var SaferBuffer = require('safer-buffer').Buffer; | ||||
| var hasSymbols = require('has-symbols'); | ||||
| var hasBigInt = typeof BigInt === 'function'; | ||||
| 
 | ||||
| test('stringify()', function (t) { | ||||
|     t.test('stringifies a querystring object', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b' }), 'a=b'); | ||||
|         st.equal(qs.stringify({ a: 1 }), 'a=1'); | ||||
|         st.equal(qs.stringify({ a: 1, b: 2 }), 'a=1&b=2'); | ||||
|         st.equal(qs.stringify({ a: 'A_Z' }), 'a=A_Z'); | ||||
|         st.equal(qs.stringify({ a: '€' }), 'a=%E2%82%AC'); | ||||
|         st.equal(qs.stringify({ a: '' }), 'a=%EE%80%80'); | ||||
|         st.equal(qs.stringify({ a: 'א' }), 'a=%D7%90'); | ||||
|         st.equal(qs.stringify({ a: '𐐷' }), 'a=%F0%90%90%B7'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies falsy values', function (st) { | ||||
|         st.equal(qs.stringify(undefined), ''); | ||||
|         st.equal(qs.stringify(null), ''); | ||||
|         st.equal(qs.stringify(null, { strictNullHandling: true }), ''); | ||||
|         st.equal(qs.stringify(false), ''); | ||||
|         st.equal(qs.stringify(0), ''); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies symbols', { skip: !hasSymbols() }, function (st) { | ||||
|         st.equal(qs.stringify(Symbol.iterator), ''); | ||||
|         st.equal(qs.stringify([Symbol.iterator]), '0=Symbol%28Symbol.iterator%29'); | ||||
|         st.equal(qs.stringify({ a: Symbol.iterator }), 'a=Symbol%28Symbol.iterator%29'); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [Symbol.iterator] }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), | ||||
|             'a[]=Symbol%28Symbol.iterator%29' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies bigints', { skip: !hasBigInt }, function (st) { | ||||
|         var three = BigInt(3); | ||||
|         var encodeWithN = function (value, defaultEncoder, charset) { | ||||
|             var result = defaultEncoder(value, defaultEncoder, charset); | ||||
|             return typeof value === 'bigint' ? result + 'n' : result; | ||||
|         }; | ||||
|         st.equal(qs.stringify(three), ''); | ||||
|         st.equal(qs.stringify([three]), '0=3'); | ||||
|         st.equal(qs.stringify([three], { encoder: encodeWithN }), '0=3n'); | ||||
|         st.equal(qs.stringify({ a: three }), 'a=3'); | ||||
|         st.equal(qs.stringify({ a: three }, { encoder: encodeWithN }), 'a=3n'); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [three] }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), | ||||
|             'a[]=3' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [three] }, { encodeValuesOnly: true, encoder: encodeWithN, arrayFormat: 'brackets' }), | ||||
|             'a[]=3n' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('adds query prefix', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b' }, { addQueryPrefix: true }), '?a=b'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('with query prefix, outputs blank string given an empty object', function (st) { | ||||
|         st.equal(qs.stringify({}, { addQueryPrefix: true }), ''); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies nested falsy values', function (st) { | ||||
|         st.equal(qs.stringify({ a: { b: { c: null } } }), 'a%5Bb%5D%5Bc%5D='); | ||||
|         st.equal(qs.stringify({ a: { b: { c: null } } }, { strictNullHandling: true }), 'a%5Bb%5D%5Bc%5D'); | ||||
|         st.equal(qs.stringify({ a: { b: { c: false } } }), 'a%5Bb%5D%5Bc%5D=false'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies a nested object', function (st) { | ||||
|         st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); | ||||
|         st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }), 'a%5Bb%5D%5Bc%5D%5Bd%5D=e'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies a nested object with dots notation', function (st) { | ||||
|         st.equal(qs.stringify({ a: { b: 'c' } }, { allowDots: true }), 'a.b=c'); | ||||
|         st.equal(qs.stringify({ a: { b: { c: { d: 'e' } } } }, { allowDots: true }), 'a.b.c.d=e'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an array value', function (st) { | ||||
|         st.equal( | ||||
|             qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'indices' }), | ||||
|             'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d', | ||||
|             'indices => indices' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'brackets' }), | ||||
|             'a%5B%5D=b&a%5B%5D=c&a%5B%5D=d', | ||||
|             'brackets => brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: ['b', 'c', 'd'] }, { arrayFormat: 'comma' }), | ||||
|             'a=b%2Cc%2Cd', | ||||
|             'comma => comma' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: ['b', 'c', 'd'] }), | ||||
|             'a%5B0%5D=b&a%5B1%5D=c&a%5B2%5D=d', | ||||
|             'default => indices' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('omits nulls when asked', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b', c: null }, { skipNulls: true }), 'a=b'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('omits nested nulls when asked', function (st) { | ||||
|         st.equal(qs.stringify({ a: { b: 'c', d: null } }, { skipNulls: true }), 'a%5Bb%5D=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('omits array indices when asked', function (st) { | ||||
|         st.equal(qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }), 'a=b&a=c&a=d'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an array value with one item vs multiple items', function (st) { | ||||
|         st.test('non-array item', function (s2t) { | ||||
|             s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a=c'); | ||||
|             s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a=c'); | ||||
|             s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true, arrayFormat: 'comma' }), 'a=c'); | ||||
|             s2t.equal(qs.stringify({ a: 'c' }, { encodeValuesOnly: true }), 'a=c'); | ||||
| 
 | ||||
|             s2t.end(); | ||||
|         }); | ||||
| 
 | ||||
|         st.test('array with a single item', function (s2t) { | ||||
|             s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a[0]=c'); | ||||
|             s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a[]=c'); | ||||
|             s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true, arrayFormat: 'comma' }), 'a=c'); | ||||
|             s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true, arrayFormat: 'comma', commaRoundTrip: true }), 'a[]=c'); // so it parses back as an array
 | ||||
|             s2t.equal(qs.stringify({ a: ['c'] }, { encodeValuesOnly: true }), 'a[0]=c'); | ||||
| 
 | ||||
|             s2t.end(); | ||||
|         }); | ||||
| 
 | ||||
|         st.test('array with multiple items', function (s2t) { | ||||
|             s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a[0]=c&a[1]=d'); | ||||
|             s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a[]=c&a[]=d'); | ||||
|             s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true, arrayFormat: 'comma' }), 'a=c,d'); | ||||
|             s2t.equal(qs.stringify({ a: ['c', 'd'] }, { encodeValuesOnly: true }), 'a[0]=c&a[1]=d'); | ||||
| 
 | ||||
|             s2t.end(); | ||||
|         }); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies a nested array value', function (st) { | ||||
|         st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { encodeValuesOnly: true, arrayFormat: 'indices' }), 'a[b][0]=c&a[b][1]=d'); | ||||
|         st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), 'a[b][]=c&a[b][]=d'); | ||||
|         st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { encodeValuesOnly: true, arrayFormat: 'comma' }), 'a[b]=c,d'); | ||||
|         st.equal(qs.stringify({ a: { b: ['c', 'd'] } }, { encodeValuesOnly: true }), 'a[b][0]=c&a[b][1]=d'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies a nested array value with dots notation', function (st) { | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: ['c', 'd'] } }, | ||||
|                 { allowDots: true, encodeValuesOnly: true, arrayFormat: 'indices' } | ||||
|             ), | ||||
|             'a.b[0]=c&a.b[1]=d', | ||||
|             'indices: stringifies with dots + indices' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: ['c', 'd'] } }, | ||||
|                 { allowDots: true, encodeValuesOnly: true, arrayFormat: 'brackets' } | ||||
|             ), | ||||
|             'a.b[]=c&a.b[]=d', | ||||
|             'brackets: stringifies with dots + brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: ['c', 'd'] } }, | ||||
|                 { allowDots: true, encodeValuesOnly: true, arrayFormat: 'comma' } | ||||
|             ), | ||||
|             'a.b=c,d', | ||||
|             'comma: stringifies with dots + comma' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: ['c', 'd'] } }, | ||||
|                 { allowDots: true, encodeValuesOnly: true } | ||||
|             ), | ||||
|             'a.b[0]=c&a.b[1]=d', | ||||
|             'default: stringifies with dots + indices' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an object inside an array', function (st) { | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'indices' }), | ||||
|             'a%5B0%5D%5Bb%5D=c', // a[0][b]=c
 | ||||
|             'indices => brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: 'c' }] }, { arrayFormat: 'brackets' }), | ||||
|             'a%5B%5D%5Bb%5D=c', // a[][b]=c
 | ||||
|             'brackets => brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: 'c' }] }), | ||||
|             'a%5B0%5D%5Bb%5D=c', | ||||
|             'default => indices' | ||||
|         ); | ||||
| 
 | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: { c: [1] } }] }, { arrayFormat: 'indices' }), | ||||
|             'a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1', | ||||
|             'indices => indices' | ||||
|         ); | ||||
| 
 | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: { c: [1] } }] }, { arrayFormat: 'brackets' }), | ||||
|             'a%5B%5D%5Bb%5D%5Bc%5D%5B%5D=1', | ||||
|             'brackets => brackets' | ||||
|         ); | ||||
| 
 | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: { c: [1] } }] }), | ||||
|             'a%5B0%5D%5Bb%5D%5Bc%5D%5B0%5D=1', | ||||
|             'default => indices' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an array with mixed objects and primitives', function (st) { | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encodeValuesOnly: true, arrayFormat: 'indices' }), | ||||
|             'a[0][b]=1&a[1]=2&a[2]=3', | ||||
|             'indices => indices' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encodeValuesOnly: true, arrayFormat: 'brackets' }), | ||||
|             'a[][b]=1&a[]=2&a[]=3', | ||||
|             'brackets => brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encodeValuesOnly: true, arrayFormat: 'comma' }), | ||||
|             '???', | ||||
|             'brackets => brackets', | ||||
|             { skip: 'TODO: figure out what this should do' } | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: [{ b: 1 }, 2, 3] }, { encodeValuesOnly: true }), | ||||
|             'a[0][b]=1&a[1]=2&a[2]=3', | ||||
|             'default => indices' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an object inside an array with dots notation', function (st) { | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [{ b: 'c' }] }, | ||||
|                 { allowDots: true, encode: false, arrayFormat: 'indices' } | ||||
|             ), | ||||
|             'a[0].b=c', | ||||
|             'indices => indices' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [{ b: 'c' }] }, | ||||
|                 { allowDots: true, encode: false, arrayFormat: 'brackets' } | ||||
|             ), | ||||
|             'a[].b=c', | ||||
|             'brackets => brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [{ b: 'c' }] }, | ||||
|                 { allowDots: true, encode: false } | ||||
|             ), | ||||
|             'a[0].b=c', | ||||
|             'default => indices' | ||||
|         ); | ||||
| 
 | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [{ b: { c: [1] } }] }, | ||||
|                 { allowDots: true, encode: false, arrayFormat: 'indices' } | ||||
|             ), | ||||
|             'a[0].b.c[0]=1', | ||||
|             'indices => indices' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [{ b: { c: [1] } }] }, | ||||
|                 { allowDots: true, encode: false, arrayFormat: 'brackets' } | ||||
|             ), | ||||
|             'a[].b.c[]=1', | ||||
|             'brackets => brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [{ b: { c: [1] } }] }, | ||||
|                 { allowDots: true, encode: false } | ||||
|             ), | ||||
|             'a[0].b.c[0]=1', | ||||
|             'default => indices' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not omit object keys when indices = false', function (st) { | ||||
|         st.equal(qs.stringify({ a: [{ b: 'c' }] }, { indices: false }), 'a%5Bb%5D=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses indices notation for arrays when indices=true', function (st) { | ||||
|         st.equal(qs.stringify({ a: ['b', 'c'] }, { indices: true }), 'a%5B0%5D=b&a%5B1%5D=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses indices notation for arrays when no arrayFormat is specified', function (st) { | ||||
|         st.equal(qs.stringify({ a: ['b', 'c'] }), 'a%5B0%5D=b&a%5B1%5D=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses indices notation for arrays when no arrayFormat=indices', function (st) { | ||||
|         st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }), 'a%5B0%5D=b&a%5B1%5D=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses repeat notation for arrays when no arrayFormat=repeat', function (st) { | ||||
|         st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }), 'a=b&a=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('uses brackets notation for arrays when no arrayFormat=brackets', function (st) { | ||||
|         st.equal(qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }), 'a%5B%5D=b&a%5B%5D=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies a complicated object', function (st) { | ||||
|         st.equal(qs.stringify({ a: { b: 'c', d: 'e' } }), 'a%5Bb%5D=c&a%5Bd%5D=e'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an empty value', function (st) { | ||||
|         st.equal(qs.stringify({ a: '' }), 'a='); | ||||
|         st.equal(qs.stringify({ a: null }, { strictNullHandling: true }), 'a'); | ||||
| 
 | ||||
|         st.equal(qs.stringify({ a: '', b: '' }), 'a=&b='); | ||||
|         st.equal(qs.stringify({ a: null, b: '' }, { strictNullHandling: true }), 'a&b='); | ||||
| 
 | ||||
|         st.equal(qs.stringify({ a: { b: '' } }), 'a%5Bb%5D='); | ||||
|         st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: true }), 'a%5Bb%5D'); | ||||
|         st.equal(qs.stringify({ a: { b: null } }, { strictNullHandling: false }), 'a%5Bb%5D='); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an empty array in different arrayFormat', function (st) { | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false }), 'b[0]=&c=c'); | ||||
|         // arrayFormat default
 | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'indices' }), 'b[0]=&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'brackets' }), 'b[]=&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'repeat' }), 'b=&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma' }), 'b=&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma', commaRoundTrip: true }), 'b[]=&c=c'); | ||||
|         // with strictNullHandling
 | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'indices', strictNullHandling: true }), 'b[0]&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'brackets', strictNullHandling: true }), 'b[]&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'repeat', strictNullHandling: true }), 'b&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma', strictNullHandling: true }), 'b&c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma', strictNullHandling: true, commaRoundTrip: true }), 'b[]&c=c'); | ||||
|         // with skipNulls
 | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'indices', skipNulls: true }), 'c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'brackets', skipNulls: true }), 'c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'repeat', skipNulls: true }), 'c=c'); | ||||
|         st.equal(qs.stringify({ a: [], b: [null], c: 'c' }, { encode: false, arrayFormat: 'comma', skipNulls: true }), 'c=c'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies a null object', { skip: !Object.create }, function (st) { | ||||
|         var obj = Object.create(null); | ||||
|         obj.a = 'b'; | ||||
|         st.equal(qs.stringify(obj), 'a=b'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('returns an empty string for invalid input', function (st) { | ||||
|         st.equal(qs.stringify(undefined), ''); | ||||
|         st.equal(qs.stringify(false), ''); | ||||
|         st.equal(qs.stringify(null), ''); | ||||
|         st.equal(qs.stringify(''), ''); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an object with a null object as a child', { skip: !Object.create }, function (st) { | ||||
|         var obj = { a: Object.create(null) }; | ||||
| 
 | ||||
|         obj.a.b = 'c'; | ||||
|         st.equal(qs.stringify(obj), 'a%5Bb%5D=c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('drops keys with a value of undefined', function (st) { | ||||
|         st.equal(qs.stringify({ a: undefined }), ''); | ||||
| 
 | ||||
|         st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: true }), 'a%5Bc%5D'); | ||||
|         st.equal(qs.stringify({ a: { b: undefined, c: null } }, { strictNullHandling: false }), 'a%5Bc%5D='); | ||||
|         st.equal(qs.stringify({ a: { b: undefined, c: '' } }), 'a%5Bc%5D='); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('url encodes values', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b c' }), 'a=b%20c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies a date', function (st) { | ||||
|         var now = new Date(); | ||||
|         var str = 'a=' + encodeURIComponent(now.toISOString()); | ||||
|         st.equal(qs.stringify({ a: now }), str); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies the weird object from qs', function (st) { | ||||
|         st.equal(qs.stringify({ 'my weird field': '~q1!2"\'w$5&7/z8)?' }), 'my%20weird%20field=~q1%212%22%27w%245%267%2Fz8%29%3F'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('skips properties that are part of the object prototype', function (st) { | ||||
|         Object.prototype.crash = 'test'; | ||||
|         st.equal(qs.stringify({ a: 'b' }), 'a=b'); | ||||
|         st.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); | ||||
|         delete Object.prototype.crash; | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies boolean values', function (st) { | ||||
|         st.equal(qs.stringify({ a: true }), 'a=true'); | ||||
|         st.equal(qs.stringify({ a: { b: true } }), 'a%5Bb%5D=true'); | ||||
|         st.equal(qs.stringify({ b: false }), 'b=false'); | ||||
|         st.equal(qs.stringify({ b: { c: false } }), 'b%5Bc%5D=false'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies buffer values', function (st) { | ||||
|         st.equal(qs.stringify({ a: SaferBuffer.from('test') }), 'a=test'); | ||||
|         st.equal(qs.stringify({ a: { b: SaferBuffer.from('test') } }), 'a%5Bb%5D=test'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies an object using an alternative delimiter', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not blow up when Buffer global is missing', function (st) { | ||||
|         var tempBuffer = global.Buffer; | ||||
|         delete global.Buffer; | ||||
|         var result = qs.stringify({ a: 'b', c: 'd' }); | ||||
|         global.Buffer = tempBuffer; | ||||
|         st.equal(result, 'a=b&c=d'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not crash when parsing circular references', function (st) { | ||||
|         var a = {}; | ||||
|         a.b = a; | ||||
| 
 | ||||
|         st['throws']( | ||||
|             function () { qs.stringify({ 'foo[bar]': 'baz', 'foo[baz]': a }); }, | ||||
|             /RangeError: Cyclic object value/, | ||||
|             'cyclic values throw' | ||||
|         ); | ||||
| 
 | ||||
|         var circular = { | ||||
|             a: 'value' | ||||
|         }; | ||||
|         circular.a = circular; | ||||
|         st['throws']( | ||||
|             function () { qs.stringify(circular); }, | ||||
|             /RangeError: Cyclic object value/, | ||||
|             'cyclic values throw' | ||||
|         ); | ||||
| 
 | ||||
|         var arr = ['a']; | ||||
|         st.doesNotThrow( | ||||
|             function () { qs.stringify({ x: arr, y: arr }); }, | ||||
|             'non-cyclic values do not throw' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('non-circular duplicated references can still work', function (st) { | ||||
|         var hourOfDay = { | ||||
|             'function': 'hour_of_day' | ||||
|         }; | ||||
| 
 | ||||
|         var p1 = { | ||||
|             'function': 'gte', | ||||
|             arguments: [hourOfDay, 0] | ||||
|         }; | ||||
|         var p2 = { | ||||
|             'function': 'lte', | ||||
|             arguments: [hourOfDay, 23] | ||||
|         }; | ||||
| 
 | ||||
|         st.equal( | ||||
|             qs.stringify({ filters: { $and: [p1, p2] } }, { encodeValuesOnly: true }), | ||||
|             'filters[$and][0][function]=gte&filters[$and][0][arguments][0][function]=hour_of_day&filters[$and][0][arguments][1]=0&filters[$and][1][function]=lte&filters[$and][1][arguments][0][function]=hour_of_day&filters[$and][1][arguments][1]=23' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('selects properties when filter=array', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b' }, { filter: ['a'] }), 'a=b'); | ||||
|         st.equal(qs.stringify({ a: 1 }, { filter: [] }), ''); | ||||
| 
 | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' }, | ||||
|                 { filter: ['a', 'b', 0, 2], arrayFormat: 'indices' } | ||||
|             ), | ||||
|             'a%5Bb%5D%5B0%5D=1&a%5Bb%5D%5B2%5D=3', | ||||
|             'indices => indices' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' }, | ||||
|                 { filter: ['a', 'b', 0, 2], arrayFormat: 'brackets' } | ||||
|             ), | ||||
|             'a%5Bb%5D%5B%5D=1&a%5Bb%5D%5B%5D=3', | ||||
|             'brackets => brackets' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: [1, 2, 3, 4], c: 'd' }, c: 'f' }, | ||||
|                 { filter: ['a', 'b', 0, 2] } | ||||
|             ), | ||||
|             'a%5Bb%5D%5B0%5D=1&a%5Bb%5D%5B2%5D=3', | ||||
|             'default => indices' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('supports custom representations when filter=function', function (st) { | ||||
|         var calls = 0; | ||||
|         var obj = { a: 'b', c: 'd', e: { f: new Date(1257894000000) } }; | ||||
|         var filterFunc = function (prefix, value) { | ||||
|             calls += 1; | ||||
|             if (calls === 1) { | ||||
|                 st.equal(prefix, '', 'prefix is empty'); | ||||
|                 st.equal(value, obj); | ||||
|             } else if (prefix === 'c') { | ||||
|                 return void 0; | ||||
|             } else if (value instanceof Date) { | ||||
|                 st.equal(prefix, 'e[f]'); | ||||
|                 return value.getTime(); | ||||
|             } | ||||
|             return value; | ||||
|         }; | ||||
| 
 | ||||
|         st.equal(qs.stringify(obj, { filter: filterFunc }), 'a=b&e%5Bf%5D=1257894000000'); | ||||
|         st.equal(calls, 5); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can disable uri encoding', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b' }, { encode: false }), 'a=b'); | ||||
|         st.equal(qs.stringify({ a: { b: 'c' } }, { encode: false }), 'a[b]=c'); | ||||
|         st.equal(qs.stringify({ a: 'b', c: null }, { strictNullHandling: true, encode: false }), 'a=b&c'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can sort the keys', function (st) { | ||||
|         var sort = function (a, b) { | ||||
|             return a.localeCompare(b); | ||||
|         }; | ||||
|         st.equal(qs.stringify({ a: 'c', z: 'y', b: 'f' }, { sort: sort }), 'a=c&b=f&z=y'); | ||||
|         st.equal(qs.stringify({ a: 'c', z: { j: 'a', i: 'b' }, b: 'f' }, { sort: sort }), 'a=c&b=f&z%5Bi%5D=b&z%5Bj%5D=a'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can sort the keys at depth 3 or more too', function (st) { | ||||
|         var sort = function (a, b) { | ||||
|             return a.localeCompare(b); | ||||
|         }; | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: 'a', z: { zj: { zjb: 'zjb', zja: 'zja' }, zi: { zib: 'zib', zia: 'zia' } }, b: 'b' }, | ||||
|                 { sort: sort, encode: false } | ||||
|             ), | ||||
|             'a=a&b=b&z[zi][zia]=zia&z[zi][zib]=zib&z[zj][zja]=zja&z[zj][zjb]=zjb' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: 'a', z: { zj: { zjb: 'zjb', zja: 'zja' }, zi: { zib: 'zib', zia: 'zia' } }, b: 'b' }, | ||||
|                 { sort: null, encode: false } | ||||
|             ), | ||||
|             'a=a&z[zj][zjb]=zjb&z[zj][zja]=zja&z[zi][zib]=zib&z[zi][zia]=zia&b=b' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can stringify with custom encoding', function (st) { | ||||
|         st.equal(qs.stringify({ 県: '大阪府', '': '' }, { | ||||
|             encoder: function (str) { | ||||
|                 if (str.length === 0) { | ||||
|                     return ''; | ||||
|                 } | ||||
|                 var buf = iconv.encode(str, 'shiftjis'); | ||||
|                 var result = []; | ||||
|                 for (var i = 0; i < buf.length; ++i) { | ||||
|                     result.push(buf.readUInt8(i).toString(16)); | ||||
|                 } | ||||
|                 return '%' + result.join('%'); | ||||
|             } | ||||
|         }), '%8c%a7=%91%e5%8d%e3%95%7b&='); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('receives the default encoder as a second argument', function (st) { | ||||
|         st.plan(2); | ||||
|         qs.stringify({ a: 1 }, { | ||||
|             encoder: function (str, defaultEncoder) { | ||||
|                 st.equal(defaultEncoder, utils.encode); | ||||
|             } | ||||
|         }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('throws error with wrong encoder', function (st) { | ||||
|         st['throws'](function () { | ||||
|             qs.stringify({}, { encoder: 'string' }); | ||||
|         }, new TypeError('Encoder has to be a function.')); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('can use custom encoder for a buffer object', { skip: typeof Buffer === 'undefined' }, function (st) { | ||||
|         st.equal(qs.stringify({ a: SaferBuffer.from([1]) }, { | ||||
|             encoder: function (buffer) { | ||||
|                 if (typeof buffer === 'string') { | ||||
|                     return buffer; | ||||
|                 } | ||||
|                 return String.fromCharCode(buffer.readUInt8(0) + 97); | ||||
|             } | ||||
|         }), 'a=b'); | ||||
| 
 | ||||
|         st.equal(qs.stringify({ a: SaferBuffer.from('a b') }, { | ||||
|             encoder: function (buffer) { | ||||
|                 return buffer; | ||||
|             } | ||||
|         }), 'a=a b'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('serializeDate option', function (st) { | ||||
|         var date = new Date(); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: date }), | ||||
|             'a=' + date.toISOString().replace(/:/g, '%3A'), | ||||
|             'default is toISOString' | ||||
|         ); | ||||
| 
 | ||||
|         var mutatedDate = new Date(); | ||||
|         mutatedDate.toISOString = function () { | ||||
|             throw new SyntaxError(); | ||||
|         }; | ||||
|         st['throws'](function () { | ||||
|             mutatedDate.toISOString(); | ||||
|         }, SyntaxError); | ||||
|         st.equal( | ||||
|             qs.stringify({ a: mutatedDate }), | ||||
|             'a=' + Date.prototype.toISOString.call(mutatedDate).replace(/:/g, '%3A'), | ||||
|             'toISOString works even when method is not locally present' | ||||
|         ); | ||||
| 
 | ||||
|         var specificDate = new Date(6); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: specificDate }, | ||||
|                 { serializeDate: function (d) { return d.getTime() * 7; } } | ||||
|             ), | ||||
|             'a=42', | ||||
|             'custom serializeDate function called' | ||||
|         ); | ||||
| 
 | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [date] }, | ||||
|                 { | ||||
|                     serializeDate: function (d) { return d.getTime(); }, | ||||
|                     arrayFormat: 'comma' | ||||
|                 } | ||||
|             ), | ||||
|             'a=' + date.getTime(), | ||||
|             'works with arrayFormat comma' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: [date] }, | ||||
|                 { | ||||
|                     serializeDate: function (d) { return d.getTime(); }, | ||||
|                     arrayFormat: 'comma', | ||||
|                     commaRoundTrip: true | ||||
|                 } | ||||
|             ), | ||||
|             'a%5B%5D=' + date.getTime(), | ||||
|             'works with arrayFormat comma' | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('RFC 1738 serialization', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b c' }, { format: qs.formats.RFC1738 }), 'a=b+c'); | ||||
|         st.equal(qs.stringify({ 'a b': 'c d' }, { format: qs.formats.RFC1738 }), 'a+b=c+d'); | ||||
|         st.equal(qs.stringify({ 'a b': SaferBuffer.from('a b') }, { format: qs.formats.RFC1738 }), 'a+b=a+b'); | ||||
| 
 | ||||
|         st.equal(qs.stringify({ 'foo(ref)': 'bar' }, { format: qs.formats.RFC1738 }), 'foo(ref)=bar'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('RFC 3986 spaces serialization', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b c' }, { format: qs.formats.RFC3986 }), 'a=b%20c'); | ||||
|         st.equal(qs.stringify({ 'a b': 'c d' }, { format: qs.formats.RFC3986 }), 'a%20b=c%20d'); | ||||
|         st.equal(qs.stringify({ 'a b': SaferBuffer.from('a b') }, { format: qs.formats.RFC3986 }), 'a%20b=a%20b'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('Backward compatibility to RFC 3986', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'b c' }), 'a=b%20c'); | ||||
|         st.equal(qs.stringify({ 'a b': SaferBuffer.from('a b') }), 'a%20b=a%20b'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('Edge cases and unknown formats', function (st) { | ||||
|         ['UFO1234', false, 1234, null, {}, []].forEach(function (format) { | ||||
|             st['throws']( | ||||
|                 function () { | ||||
|                     qs.stringify({ a: 'b c' }, { format: format }); | ||||
|                 }, | ||||
|                 new TypeError('Unknown format option provided.') | ||||
|             ); | ||||
|         }); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('encodeValuesOnly', function (st) { | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] }, | ||||
|                 { encodeValuesOnly: true } | ||||
|             ), | ||||
|             'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h' | ||||
|         ); | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: 'b', c: ['d', 'e'], f: [['g'], ['h']] } | ||||
|             ), | ||||
|             'a=b&c%5B0%5D=d&c%5B1%5D=e&f%5B0%5D%5B0%5D=g&f%5B1%5D%5B0%5D=h' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('encodeValuesOnly - strictNullHandling', function (st) { | ||||
|         st.equal( | ||||
|             qs.stringify( | ||||
|                 { a: { b: null } }, | ||||
|                 { encodeValuesOnly: true, strictNullHandling: true } | ||||
|             ), | ||||
|             'a[b]' | ||||
|         ); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('throws if an invalid charset is specified', function (st) { | ||||
|         st['throws'](function () { | ||||
|             qs.stringify({ a: 'b' }, { charset: 'foobar' }); | ||||
|         }, new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined')); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('respects a charset of iso-8859-1', function (st) { | ||||
|         st.equal(qs.stringify({ æ: 'æ' }, { charset: 'iso-8859-1' }), '%E6=%E6'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('encodes unrepresentable chars as numeric entities in iso-8859-1 mode', function (st) { | ||||
|         st.equal(qs.stringify({ a: '☺' }, { charset: 'iso-8859-1' }), 'a=%26%239786%3B'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('respects an explicit charset of utf-8 (the default)', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'æ' }, { charset: 'utf-8' }), 'a=%C3%A6'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('adds the right sentinel when instructed to and the charset is utf-8', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'æ' }, { charsetSentinel: true, charset: 'utf-8' }), 'utf8=%E2%9C%93&a=%C3%A6'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('adds the right sentinel when instructed to and the charset is iso-8859-1', function (st) { | ||||
|         st.equal(qs.stringify({ a: 'æ' }, { charsetSentinel: true, charset: 'iso-8859-1' }), 'utf8=%26%2310003%3B&a=%E6'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('does not mutate the options argument', function (st) { | ||||
|         var options = {}; | ||||
|         qs.stringify({}, options); | ||||
|         st.deepEqual(options, {}); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('strictNullHandling works with custom filter', function (st) { | ||||
|         var filter = function (prefix, value) { | ||||
|             return value; | ||||
|         }; | ||||
| 
 | ||||
|         var options = { strictNullHandling: true, filter: filter }; | ||||
|         st.equal(qs.stringify({ key: null }, options), 'key'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('strictNullHandling works with null serializeDate', function (st) { | ||||
|         var serializeDate = function () { | ||||
|             return null; | ||||
|         }; | ||||
|         var options = { strictNullHandling: true, serializeDate: serializeDate }; | ||||
|         var date = new Date(); | ||||
|         st.equal(qs.stringify({ key: date }, options), 'key'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('allows for encoding keys and values differently', function (st) { | ||||
|         var encoder = function (str, defaultEncoder, charset, type) { | ||||
|             if (type === 'key') { | ||||
|                 return defaultEncoder(str, defaultEncoder, charset, type).toLowerCase(); | ||||
|             } | ||||
|             if (type === 'value') { | ||||
|                 return defaultEncoder(str, defaultEncoder, charset, type).toUpperCase(); | ||||
|             } | ||||
|             throw 'this should never happen! type: ' + type; | ||||
|         }; | ||||
| 
 | ||||
|         st.deepEqual(qs.stringify({ KeY: 'vAlUe' }, { encoder: encoder }), 'key=VALUE'); | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('objects inside arrays', function (st) { | ||||
|         var obj = { a: { b: { c: 'd', e: 'f' } } }; | ||||
|         var withArray = { a: { b: [{ c: 'd', e: 'f' }] } }; | ||||
| 
 | ||||
|         st.equal(qs.stringify(obj, { encode: false }), 'a[b][c]=d&a[b][e]=f', 'no array, no arrayFormat'); | ||||
|         st.equal(qs.stringify(obj, { encode: false, arrayFormat: 'bracket' }), 'a[b][c]=d&a[b][e]=f', 'no array, bracket'); | ||||
|         st.equal(qs.stringify(obj, { encode: false, arrayFormat: 'indices' }), 'a[b][c]=d&a[b][e]=f', 'no array, indices'); | ||||
|         st.equal(qs.stringify(obj, { encode: false, arrayFormat: 'comma' }), 'a[b][c]=d&a[b][e]=f', 'no array, comma'); | ||||
| 
 | ||||
|         st.equal(qs.stringify(withArray, { encode: false }), 'a[b][0][c]=d&a[b][0][e]=f', 'array, no arrayFormat'); | ||||
|         st.equal(qs.stringify(withArray, { encode: false, arrayFormat: 'bracket' }), 'a[b][0][c]=d&a[b][0][e]=f', 'array, bracket'); | ||||
|         st.equal(qs.stringify(withArray, { encode: false, arrayFormat: 'indices' }), 'a[b][0][c]=d&a[b][0][e]=f', 'array, indices'); | ||||
|         st.equal( | ||||
|             qs.stringify(withArray, { encode: false, arrayFormat: 'comma' }), | ||||
|             '???', | ||||
|             'array, comma', | ||||
|             { skip: 'TODO: figure out what this should do' } | ||||
|         ); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('stringifies sparse arrays', function (st) { | ||||
|         /* eslint no-sparse-arrays: 0 */ | ||||
|         st.equal(qs.stringify({ a: [, '2', , , '1'] }, { encodeValuesOnly: true }), 'a[1]=2&a[4]=1'); | ||||
|         st.equal(qs.stringify({ a: [, { b: [, , { c: '1' }] }] }, { encodeValuesOnly: true }), 'a[1][b][2][c]=1'); | ||||
|         st.equal(qs.stringify({ a: [, [, , [, , , { c: '1' }]]] }, { encodeValuesOnly: true }), 'a[1][2][3][c]=1'); | ||||
|         st.equal(qs.stringify({ a: [, [, , [, , , { c: [, '1'] }]]] }, { encodeValuesOnly: true }), 'a[1][2][3][c][1]=1'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.end(); | ||||
| }); | ||||
							
								
								
									
										136
									
								
								node_modules/superagent/node_modules/qs/test/utils.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								node_modules/superagent/node_modules/qs/test/utils.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,136 @@ | |||
| 'use strict'; | ||||
| 
 | ||||
| var test = require('tape'); | ||||
| var inspect = require('object-inspect'); | ||||
| var SaferBuffer = require('safer-buffer').Buffer; | ||||
| var forEach = require('for-each'); | ||||
| var utils = require('../lib/utils'); | ||||
| 
 | ||||
| test('merge()', function (t) { | ||||
|     t.deepEqual(utils.merge(null, true), [null, true], 'merges true into null'); | ||||
| 
 | ||||
|     t.deepEqual(utils.merge(null, [42]), [null, 42], 'merges null into an array'); | ||||
| 
 | ||||
|     t.deepEqual(utils.merge({ a: 'b' }, { a: 'c' }), { a: ['b', 'c'] }, 'merges two objects with the same key'); | ||||
| 
 | ||||
|     var oneMerged = utils.merge({ foo: 'bar' }, { foo: { first: '123' } }); | ||||
|     t.deepEqual(oneMerged, { foo: ['bar', { first: '123' }] }, 'merges a standalone and an object into an array'); | ||||
| 
 | ||||
|     var twoMerged = utils.merge({ foo: ['bar', { first: '123' }] }, { foo: { second: '456' } }); | ||||
|     t.deepEqual(twoMerged, { foo: { 0: 'bar', 1: { first: '123' }, second: '456' } }, 'merges a standalone and two objects into an array'); | ||||
| 
 | ||||
|     var sandwiched = utils.merge({ foo: ['bar', { first: '123', second: '456' }] }, { foo: 'baz' }); | ||||
|     t.deepEqual(sandwiched, { foo: ['bar', { first: '123', second: '456' }, 'baz'] }, 'merges an object sandwiched by two standalones into an array'); | ||||
| 
 | ||||
|     var nestedArrays = utils.merge({ foo: ['baz'] }, { foo: ['bar', 'xyzzy'] }); | ||||
|     t.deepEqual(nestedArrays, { foo: ['baz', 'bar', 'xyzzy'] }); | ||||
| 
 | ||||
|     var noOptionsNonObjectSource = utils.merge({ foo: 'baz' }, 'bar'); | ||||
|     t.deepEqual(noOptionsNonObjectSource, { foo: 'baz', bar: true }); | ||||
| 
 | ||||
|     t.test( | ||||
|         'avoids invoking array setters unnecessarily', | ||||
|         { skip: typeof Object.defineProperty !== 'function' }, | ||||
|         function (st) { | ||||
|             var setCount = 0; | ||||
|             var getCount = 0; | ||||
|             var observed = []; | ||||
|             Object.defineProperty(observed, 0, { | ||||
|                 get: function () { | ||||
|                     getCount += 1; | ||||
|                     return { bar: 'baz' }; | ||||
|                 }, | ||||
|                 set: function () { setCount += 1; } | ||||
|             }); | ||||
|             utils.merge(observed, [null]); | ||||
|             st.equal(setCount, 0); | ||||
|             st.equal(getCount, 1); | ||||
|             observed[0] = observed[0]; // eslint-disable-line no-self-assign
 | ||||
|             st.equal(setCount, 1); | ||||
|             st.equal(getCount, 2); | ||||
|             st.end(); | ||||
|         } | ||||
|     ); | ||||
| 
 | ||||
|     t.end(); | ||||
| }); | ||||
| 
 | ||||
| test('assign()', function (t) { | ||||
|     var target = { a: 1, b: 2 }; | ||||
|     var source = { b: 3, c: 4 }; | ||||
|     var result = utils.assign(target, source); | ||||
| 
 | ||||
|     t.equal(result, target, 'returns the target'); | ||||
|     t.deepEqual(target, { a: 1, b: 3, c: 4 }, 'target and source are merged'); | ||||
|     t.deepEqual(source, { b: 3, c: 4 }, 'source is untouched'); | ||||
| 
 | ||||
|     t.end(); | ||||
| }); | ||||
| 
 | ||||
| test('combine()', function (t) { | ||||
|     t.test('both arrays', function (st) { | ||||
|         var a = [1]; | ||||
|         var b = [2]; | ||||
|         var combined = utils.combine(a, b); | ||||
| 
 | ||||
|         st.deepEqual(a, [1], 'a is not mutated'); | ||||
|         st.deepEqual(b, [2], 'b is not mutated'); | ||||
|         st.notEqual(a, combined, 'a !== combined'); | ||||
|         st.notEqual(b, combined, 'b !== combined'); | ||||
|         st.deepEqual(combined, [1, 2], 'combined is a + b'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('one array, one non-array', function (st) { | ||||
|         var aN = 1; | ||||
|         var a = [aN]; | ||||
|         var bN = 2; | ||||
|         var b = [bN]; | ||||
| 
 | ||||
|         var combinedAnB = utils.combine(aN, b); | ||||
|         st.deepEqual(b, [bN], 'b is not mutated'); | ||||
|         st.notEqual(aN, combinedAnB, 'aN + b !== aN'); | ||||
|         st.notEqual(a, combinedAnB, 'aN + b !== a'); | ||||
|         st.notEqual(bN, combinedAnB, 'aN + b !== bN'); | ||||
|         st.notEqual(b, combinedAnB, 'aN + b !== b'); | ||||
|         st.deepEqual([1, 2], combinedAnB, 'first argument is array-wrapped when not an array'); | ||||
| 
 | ||||
|         var combinedABn = utils.combine(a, bN); | ||||
|         st.deepEqual(a, [aN], 'a is not mutated'); | ||||
|         st.notEqual(aN, combinedABn, 'a + bN !== aN'); | ||||
|         st.notEqual(a, combinedABn, 'a + bN !== a'); | ||||
|         st.notEqual(bN, combinedABn, 'a + bN !== bN'); | ||||
|         st.notEqual(b, combinedABn, 'a + bN !== b'); | ||||
|         st.deepEqual([1, 2], combinedABn, 'second argument is array-wrapped when not an array'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.test('neither is an array', function (st) { | ||||
|         var combined = utils.combine(1, 2); | ||||
|         st.notEqual(1, combined, '1 + 2 !== 1'); | ||||
|         st.notEqual(2, combined, '1 + 2 !== 2'); | ||||
|         st.deepEqual([1, 2], combined, 'both arguments are array-wrapped when not an array'); | ||||
| 
 | ||||
|         st.end(); | ||||
|     }); | ||||
| 
 | ||||
|     t.end(); | ||||
| }); | ||||
| 
 | ||||
| test('isBuffer()', function (t) { | ||||
|     forEach([null, undefined, true, false, '', 'abc', 42, 0, NaN, {}, [], function () {}, /a/g], function (x) { | ||||
|         t.equal(utils.isBuffer(x), false, inspect(x) + ' is not a buffer'); | ||||
|     }); | ||||
| 
 | ||||
|     var fakeBuffer = { constructor: Buffer }; | ||||
|     t.equal(utils.isBuffer(fakeBuffer), false, 'fake buffer is not a buffer'); | ||||
| 
 | ||||
|     var saferBuffer = SaferBuffer.from('abc'); | ||||
|     t.equal(utils.isBuffer(saferBuffer), true, 'SaferBuffer instance is a buffer'); | ||||
| 
 | ||||
|     var buffer = Buffer.from && Buffer.alloc ? Buffer.from('abc') : new Buffer('abc'); | ||||
|     t.equal(utils.isBuffer(buffer), true, 'real Buffer instance is a buffer'); | ||||
|     t.end(); | ||||
| }); | ||||
							
								
								
									
										136
									
								
								node_modules/superagent/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								node_modules/superagent/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,136 @@ | |||
| { | ||||
|   "name": "superagent", | ||||
|   "description": "elegant & feature rich browser / node HTTP with a fluent API", | ||||
|   "version": "7.1.5", | ||||
|   "author": "TJ Holowaychuk <tj@vision-media.ca>", | ||||
|   "browser": { | ||||
|     "./src/node/index.js": "./src/client.js", | ||||
|     "./lib/node/index.js": "./lib/client.js", | ||||
|     "./test/support/server.js": "./test/support/blank.js", | ||||
|     "semver": false | ||||
|   }, | ||||
|   "bugs": { | ||||
|     "url": "https://github.com/visionmedia/superagent/issues" | ||||
|   }, | ||||
|   "contributors": [ | ||||
|     "Kornel Lesiński <kornel@geekhood.net>", | ||||
|     "Peter Lyons <pete@peterlyons.com>", | ||||
|     "Hunter Loftis <hunter@hunterloftis.com>", | ||||
|     "Nick Baugh <niftylettuce@gmail.com>" | ||||
|   ], | ||||
|   "dependencies": { | ||||
|     "component-emitter": "^1.3.0", | ||||
|     "cookiejar": "^2.1.3", | ||||
|     "debug": "^4.3.4", | ||||
|     "fast-safe-stringify": "^2.1.1", | ||||
|     "form-data": "^4.0.0", | ||||
|     "formidable": "^2.0.1", | ||||
|     "methods": "^1.1.2", | ||||
|     "mime": "^2.5.0", | ||||
|     "qs": "^6.10.3", | ||||
|     "readable-stream": "^3.6.0", | ||||
|     "semver": "^7.3.7" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@babel/cli": "^7.17.10", | ||||
|     "@babel/core": "^7.18.2", | ||||
|     "@babel/plugin-transform-runtime": "^7.18.2", | ||||
|     "@babel/preset-env": "^7.18.2", | ||||
|     "@babel/runtime": "^7.18.3", | ||||
|     "@commitlint/cli": "^17.0.1", | ||||
|     "@commitlint/config-conventional": "^17.0.0", | ||||
|     "Base64": "^1.1.0", | ||||
|     "babelify": "^10.0.0", | ||||
|     "basic-auth-connect": "^1.0.0", | ||||
|     "body-parser": "^1.20.0", | ||||
|     "browserify": "^17.0.0", | ||||
|     "codecov": "^3.8.3", | ||||
|     "cookie-parser": "^1.4.6", | ||||
|     "cross-env": "^7.0.3", | ||||
|     "eslint": "^8.16.0", | ||||
|     "eslint-config-xo-lass": "^1.0.6", | ||||
|     "eslint-plugin-compat": "^4.0.2", | ||||
|     "eslint-plugin-node": "^11.1.0", | ||||
|     "express": "^4.18.1", | ||||
|     "express-session": "^1.17.3", | ||||
|     "fixpack": "^4.0.0", | ||||
|     "get-port": "4.2.0", | ||||
|     "husky": "^8.0.1", | ||||
|     "lint-staged": "^12.5.0", | ||||
|     "marked": "^2.0.0", | ||||
|     "mocha": "6.2.2", | ||||
|     "multer": "^1.4.4", | ||||
|     "nyc": "^15.1.0", | ||||
|     "remark-cli": "^10.0.1", | ||||
|     "remark-preset-github": "^4.0.1", | ||||
|     "rimraf": "^3.0.2", | ||||
|     "should": "^13.2.3", | ||||
|     "should-http": "^0.1.1", | ||||
|     "tinyify": "^3.0.0", | ||||
|     "xo": "^0.49.0", | ||||
|     "zuul": "^3.12.0" | ||||
|   }, | ||||
|   "engines": { | ||||
|     "node": ">=6.4.0 <13 || >=14" | ||||
|   }, | ||||
|   "files": [ | ||||
|     "dist/*.js", | ||||
|     "lib/**/*.js" | ||||
|   ], | ||||
|   "homepage": "https://github.com/visionmedia/superagent", | ||||
|   "jsdelivr": "dist/superagent.min.js", | ||||
|   "keywords": [ | ||||
|     "agent", | ||||
|     "ajax", | ||||
|     "ajax", | ||||
|     "api", | ||||
|     "async", | ||||
|     "await", | ||||
|     "axios", | ||||
|     "cancel", | ||||
|     "client", | ||||
|     "frisbee", | ||||
|     "got", | ||||
|     "http", | ||||
|     "http", | ||||
|     "https", | ||||
|     "ky", | ||||
|     "promise", | ||||
|     "promise", | ||||
|     "promises", | ||||
|     "request", | ||||
|     "request", | ||||
|     "requests", | ||||
|     "response", | ||||
|     "rest", | ||||
|     "retry", | ||||
|     "super", | ||||
|     "superagent", | ||||
|     "timeout", | ||||
|     "transform", | ||||
|     "xhr", | ||||
|     "xmlhttprequest" | ||||
|   ], | ||||
|   "license": "MIT", | ||||
|   "main": "lib/node/index.js", | ||||
|   "repository": { | ||||
|     "type": "git", | ||||
|     "url": "git://github.com/visionmedia/superagent.git" | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "browserify": "browserify src/node/index.js -o dist/superagent.js -s superagent -g [ babelify --configFile ./.dist.babelrc ]", | ||||
|     "build": "npm run build:clean && npm run build:lib && npm run build:dist", | ||||
|     "build:clean": "rimraf lib dist", | ||||
|     "build:dist": "npm run browserify && npm run minify", | ||||
|     "build:lib": "babel --config-file ./.lib.babelrc src --out-dir lib", | ||||
|     "build:test": "babel --config-file ./.test.babelrc test --out-dir lib/node/test", | ||||
|     "coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||||
|     "lint": "eslint -c .eslintrc src test && remark . -qfo && eslint -c .lib.eslintrc lib/**/*.js && eslint -c .dist.eslintrc dist/**/*.js", | ||||
|     "minify": "cross-env NODE_ENV=production browserify src/node/index.js -o dist/superagent.min.js -s superagent -g [ babelify --configFile ./.dist.babelrc ] -p tinyify", | ||||
|     "nyc": "cross-env NODE_ENV=test nyc ava", | ||||
|     "prepare": "husky install", | ||||
|     "test": "npm run build && npm run lint && make test", | ||||
|     "test-http2": "npm run build && npm run lint && make test-node-http2" | ||||
|   }, | ||||
|   "unpkg": "dist/superagent.min.js" | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue