es6-crawler-detect 3.3.0 → 4.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/.babelrc +1 -1
  2. package/.mocharc.json +5 -0
  3. package/README.md +1 -0
  4. package/dist/index.d.ts +5 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +18 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/crawler/crawlers.d.ts +5 -0
  9. package/dist/lib/crawler/crawlers.d.ts.map +1 -0
  10. package/dist/lib/crawler/crawlers.js +1400 -0
  11. package/dist/lib/crawler/crawlers.js.map +1 -0
  12. package/dist/lib/crawler/exclusions.d.ts +5 -0
  13. package/dist/lib/crawler/exclusions.d.ts.map +1 -0
  14. package/dist/lib/crawler/exclusions.js +59 -0
  15. package/dist/lib/crawler/exclusions.js.map +1 -0
  16. package/dist/lib/crawler/headers.d.ts +5 -0
  17. package/dist/lib/crawler/headers.d.ts.map +1 -0
  18. package/dist/lib/crawler/headers.js +21 -0
  19. package/dist/lib/crawler/headers.js.map +1 -0
  20. package/dist/lib/crawler/provider.d.ts +4 -0
  21. package/dist/lib/crawler/provider.d.ts.map +1 -0
  22. package/dist/lib/crawler/provider.js +3 -0
  23. package/dist/lib/crawler/provider.js.map +1 -0
  24. package/dist/lib/crawler.d.ts +21 -0
  25. package/dist/lib/crawler.d.ts.map +1 -0
  26. package/dist/lib/crawler.js +98 -0
  27. package/dist/lib/crawler.js.map +1 -0
  28. package/dist/types.d.ts +9 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +3 -0
  31. package/dist/types.js.map +1 -0
  32. package/eslint.config.mjs +62 -0
  33. package/example/node/package.json +1 -1
  34. package/example/node/yarn.lock +222 -99
  35. package/package.json +30 -24
  36. package/src/index.ts +18 -0
  37. package/src/lib/crawler/{crawlers.js → crawlers.ts} +1397 -1403
  38. package/src/lib/crawler/{exclusions.js → exclusions.ts} +56 -62
  39. package/src/lib/crawler/{headers.js → headers.ts} +4 -10
  40. package/src/lib/crawler/provider.ts +3 -0
  41. package/src/lib/crawler.ts +128 -0
  42. package/src/types.ts +15 -0
  43. package/test/lib/crawler.spec.ts +116 -0
  44. package/tsconfig.json +28 -0
  45. package/.eslintignore +0 -6
  46. package/.eslintrc.json +0 -30
  47. package/dist/main.bundle.js +0 -1
  48. package/example/node/dist/crawler.min.js +0 -1
  49. package/example/node/node_modules/.bin/mime +0 -15
  50. package/example/node/node_modules/.bin/mime.cmd +0 -7
  51. package/example/node/node_modules/.yarn-integrity +0 -67
  52. package/example/node/node_modules/accepts/HISTORY.md +0 -236
  53. package/example/node/node_modules/accepts/LICENSE +0 -23
  54. package/example/node/node_modules/accepts/README.md +0 -142
  55. package/example/node/node_modules/accepts/index.js +0 -238
  56. package/example/node/node_modules/accepts/package.json +0 -47
  57. package/example/node/node_modules/array-flatten/LICENSE +0 -21
  58. package/example/node/node_modules/array-flatten/README.md +0 -43
  59. package/example/node/node_modules/array-flatten/array-flatten.js +0 -64
  60. package/example/node/node_modules/array-flatten/package.json +0 -39
  61. package/example/node/node_modules/body-parser/HISTORY.md +0 -624
  62. package/example/node/node_modules/body-parser/LICENSE +0 -23
  63. package/example/node/node_modules/body-parser/README.md +0 -456
  64. package/example/node/node_modules/body-parser/index.js +0 -157
  65. package/example/node/node_modules/body-parser/lib/read.js +0 -181
  66. package/example/node/node_modules/body-parser/lib/types/json.js +0 -230
  67. package/example/node/node_modules/body-parser/lib/types/raw.js +0 -101
  68. package/example/node/node_modules/body-parser/lib/types/text.js +0 -121
  69. package/example/node/node_modules/body-parser/lib/types/urlencoded.js +0 -284
  70. package/example/node/node_modules/body-parser/package.json +0 -52
  71. package/example/node/node_modules/bytes/History.md +0 -92
  72. package/example/node/node_modules/bytes/LICENSE +0 -23
  73. package/example/node/node_modules/bytes/Readme.md +0 -152
  74. package/example/node/node_modules/bytes/index.js +0 -166
  75. package/example/node/node_modules/bytes/package.json +0 -42
  76. package/example/node/node_modules/content-disposition/HISTORY.md +0 -60
  77. package/example/node/node_modules/content-disposition/LICENSE +0 -22
  78. package/example/node/node_modules/content-disposition/README.md +0 -142
  79. package/example/node/node_modules/content-disposition/index.js +0 -458
  80. package/example/node/node_modules/content-disposition/package.json +0 -44
  81. package/example/node/node_modules/content-type/HISTORY.md +0 -24
  82. package/example/node/node_modules/content-type/LICENSE +0 -22
  83. package/example/node/node_modules/content-type/README.md +0 -92
  84. package/example/node/node_modules/content-type/index.js +0 -222
  85. package/example/node/node_modules/content-type/package.json +0 -40
  86. package/example/node/node_modules/cookie/HISTORY.md +0 -128
  87. package/example/node/node_modules/cookie/LICENSE +0 -24
  88. package/example/node/node_modules/cookie/README.md +0 -257
  89. package/example/node/node_modules/cookie/index.js +0 -202
  90. package/example/node/node_modules/cookie/package.json +0 -40
  91. package/example/node/node_modules/cookie-signature/History.md +0 -38
  92. package/example/node/node_modules/cookie-signature/Readme.md +0 -42
  93. package/example/node/node_modules/cookie-signature/index.js +0 -51
  94. package/example/node/node_modules/cookie-signature/package.json +0 -18
  95. package/example/node/node_modules/debug/.coveralls.yml +0 -1
  96. package/example/node/node_modules/debug/.eslintrc +0 -11
  97. package/example/node/node_modules/debug/.travis.yml +0 -14
  98. package/example/node/node_modules/debug/CHANGELOG.md +0 -362
  99. package/example/node/node_modules/debug/LICENSE +0 -19
  100. package/example/node/node_modules/debug/Makefile +0 -50
  101. package/example/node/node_modules/debug/README.md +0 -312
  102. package/example/node/node_modules/debug/component.json +0 -19
  103. package/example/node/node_modules/debug/karma.conf.js +0 -70
  104. package/example/node/node_modules/debug/node.js +0 -1
  105. package/example/node/node_modules/debug/package.json +0 -49
  106. package/example/node/node_modules/debug/src/browser.js +0 -185
  107. package/example/node/node_modules/debug/src/debug.js +0 -202
  108. package/example/node/node_modules/debug/src/index.js +0 -10
  109. package/example/node/node_modules/debug/src/inspector-log.js +0 -15
  110. package/example/node/node_modules/debug/src/node.js +0 -248
  111. package/example/node/node_modules/depd/History.md +0 -96
  112. package/example/node/node_modules/depd/LICENSE +0 -22
  113. package/example/node/node_modules/depd/Readme.md +0 -280
  114. package/example/node/node_modules/depd/index.js +0 -522
  115. package/example/node/node_modules/depd/lib/browser/index.js +0 -77
  116. package/example/node/node_modules/depd/lib/compat/callsite-tostring.js +0 -103
  117. package/example/node/node_modules/depd/lib/compat/event-listener-count.js +0 -22
  118. package/example/node/node_modules/depd/lib/compat/index.js +0 -79
  119. package/example/node/node_modules/depd/package.json +0 -41
  120. package/example/node/node_modules/destroy/LICENSE +0 -22
  121. package/example/node/node_modules/destroy/README.md +0 -60
  122. package/example/node/node_modules/destroy/index.js +0 -75
  123. package/example/node/node_modules/destroy/package.json +0 -37
  124. package/example/node/node_modules/ee-first/LICENSE +0 -22
  125. package/example/node/node_modules/ee-first/README.md +0 -80
  126. package/example/node/node_modules/ee-first/index.js +0 -95
  127. package/example/node/node_modules/ee-first/package.json +0 -29
  128. package/example/node/node_modules/encodeurl/HISTORY.md +0 -14
  129. package/example/node/node_modules/encodeurl/LICENSE +0 -22
  130. package/example/node/node_modules/encodeurl/README.md +0 -128
  131. package/example/node/node_modules/encodeurl/index.js +0 -60
  132. package/example/node/node_modules/encodeurl/package.json +0 -40
  133. package/example/node/node_modules/escape-html/LICENSE +0 -24
  134. package/example/node/node_modules/escape-html/Readme.md +0 -43
  135. package/example/node/node_modules/escape-html/index.js +0 -78
  136. package/example/node/node_modules/escape-html/package.json +0 -24
  137. package/example/node/node_modules/etag/HISTORY.md +0 -83
  138. package/example/node/node_modules/etag/LICENSE +0 -22
  139. package/example/node/node_modules/etag/README.md +0 -159
  140. package/example/node/node_modules/etag/index.js +0 -131
  141. package/example/node/node_modules/etag/package.json +0 -47
  142. package/example/node/node_modules/express/History.md +0 -3510
  143. package/example/node/node_modules/express/LICENSE +0 -24
  144. package/example/node/node_modules/express/Readme.md +0 -158
  145. package/example/node/node_modules/express/index.js +0 -11
  146. package/example/node/node_modules/express/lib/application.js +0 -644
  147. package/example/node/node_modules/express/lib/express.js +0 -116
  148. package/example/node/node_modules/express/lib/middleware/init.js +0 -43
  149. package/example/node/node_modules/express/lib/middleware/query.js +0 -47
  150. package/example/node/node_modules/express/lib/request.js +0 -525
  151. package/example/node/node_modules/express/lib/response.js +0 -1147
  152. package/example/node/node_modules/express/lib/router/index.js +0 -668
  153. package/example/node/node_modules/express/lib/router/layer.js +0 -181
  154. package/example/node/node_modules/express/lib/router/route.js +0 -216
  155. package/example/node/node_modules/express/lib/utils.js +0 -302
  156. package/example/node/node_modules/express/lib/view.js +0 -182
  157. package/example/node/node_modules/express/package.json +0 -99
  158. package/example/node/node_modules/finalhandler/HISTORY.md +0 -187
  159. package/example/node/node_modules/finalhandler/LICENSE +0 -22
  160. package/example/node/node_modules/finalhandler/README.md +0 -148
  161. package/example/node/node_modules/finalhandler/index.js +0 -331
  162. package/example/node/node_modules/finalhandler/package.json +0 -45
  163. package/example/node/node_modules/forwarded/HISTORY.md +0 -21
  164. package/example/node/node_modules/forwarded/LICENSE +0 -22
  165. package/example/node/node_modules/forwarded/README.md +0 -57
  166. package/example/node/node_modules/forwarded/index.js +0 -90
  167. package/example/node/node_modules/forwarded/package.json +0 -45
  168. package/example/node/node_modules/fresh/HISTORY.md +0 -70
  169. package/example/node/node_modules/fresh/LICENSE +0 -23
  170. package/example/node/node_modules/fresh/README.md +0 -119
  171. package/example/node/node_modules/fresh/index.js +0 -137
  172. package/example/node/node_modules/fresh/package.json +0 -46
  173. package/example/node/node_modules/http-errors/HISTORY.md +0 -165
  174. package/example/node/node_modules/http-errors/LICENSE +0 -23
  175. package/example/node/node_modules/http-errors/README.md +0 -169
  176. package/example/node/node_modules/http-errors/index.js +0 -299
  177. package/example/node/node_modules/http-errors/package.json +0 -49
  178. package/example/node/node_modules/iconv-lite/Changelog.md +0 -162
  179. package/example/node/node_modules/iconv-lite/LICENSE +0 -21
  180. package/example/node/node_modules/iconv-lite/README.md +0 -156
  181. package/example/node/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -555
  182. package/example/node/node_modules/iconv-lite/encodings/dbcs-data.js +0 -176
  183. package/example/node/node_modules/iconv-lite/encodings/index.js +0 -22
  184. package/example/node/node_modules/iconv-lite/encodings/internal.js +0 -188
  185. package/example/node/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  186. package/example/node/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  187. package/example/node/node_modules/iconv-lite/encodings/sbcs-data.js +0 -174
  188. package/example/node/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  189. package/example/node/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  190. package/example/node/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  191. package/example/node/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  192. package/example/node/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  193. package/example/node/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  194. package/example/node/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -55
  195. package/example/node/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  196. package/example/node/node_modules/iconv-lite/encodings/utf16.js +0 -177
  197. package/example/node/node_modules/iconv-lite/encodings/utf7.js +0 -290
  198. package/example/node/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  199. package/example/node/node_modules/iconv-lite/lib/extend-node.js +0 -217
  200. package/example/node/node_modules/iconv-lite/lib/index.d.ts +0 -24
  201. package/example/node/node_modules/iconv-lite/lib/index.js +0 -153
  202. package/example/node/node_modules/iconv-lite/lib/streams.js +0 -121
  203. package/example/node/node_modules/iconv-lite/package.json +0 -46
  204. package/example/node/node_modules/inherits/LICENSE +0 -16
  205. package/example/node/node_modules/inherits/README.md +0 -42
  206. package/example/node/node_modules/inherits/inherits.js +0 -9
  207. package/example/node/node_modules/inherits/inherits_browser.js +0 -27
  208. package/example/node/node_modules/inherits/package.json +0 -29
  209. package/example/node/node_modules/ipaddr.js/LICENSE +0 -19
  210. package/example/node/node_modules/ipaddr.js/README.md +0 -233
  211. package/example/node/node_modules/ipaddr.js/ipaddr.min.js +0 -1
  212. package/example/node/node_modules/ipaddr.js/lib/ipaddr.js +0 -673
  213. package/example/node/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +0 -68
  214. package/example/node/node_modules/ipaddr.js/package.json +0 -35
  215. package/example/node/node_modules/media-typer/HISTORY.md +0 -22
  216. package/example/node/node_modules/media-typer/LICENSE +0 -22
  217. package/example/node/node_modules/media-typer/README.md +0 -81
  218. package/example/node/node_modules/media-typer/index.js +0 -270
  219. package/example/node/node_modules/media-typer/package.json +0 -26
  220. package/example/node/node_modules/merge-descriptors/HISTORY.md +0 -21
  221. package/example/node/node_modules/merge-descriptors/LICENSE +0 -23
  222. package/example/node/node_modules/merge-descriptors/README.md +0 -48
  223. package/example/node/node_modules/merge-descriptors/index.js +0 -60
  224. package/example/node/node_modules/merge-descriptors/package.json +0 -32
  225. package/example/node/node_modules/methods/HISTORY.md +0 -29
  226. package/example/node/node_modules/methods/LICENSE +0 -24
  227. package/example/node/node_modules/methods/README.md +0 -51
  228. package/example/node/node_modules/methods/index.js +0 -69
  229. package/example/node/node_modules/methods/package.json +0 -36
  230. package/example/node/node_modules/mime/CHANGELOG.md +0 -164
  231. package/example/node/node_modules/mime/LICENSE +0 -21
  232. package/example/node/node_modules/mime/README.md +0 -90
  233. package/example/node/node_modules/mime/cli.js +0 -8
  234. package/example/node/node_modules/mime/mime.js +0 -108
  235. package/example/node/node_modules/mime/package.json +0 -44
  236. package/example/node/node_modules/mime/src/build.js +0 -53
  237. package/example/node/node_modules/mime/src/test.js +0 -60
  238. package/example/node/node_modules/mime/types.json +0 -1
  239. package/example/node/node_modules/mime-db/HISTORY.md +0 -499
  240. package/example/node/node_modules/mime-db/LICENSE +0 -22
  241. package/example/node/node_modules/mime-db/README.md +0 -100
  242. package/example/node/node_modules/mime-db/db.json +0 -8471
  243. package/example/node/node_modules/mime-db/index.js +0 -11
  244. package/example/node/node_modules/mime-db/package.json +0 -59
  245. package/example/node/node_modules/mime-types/HISTORY.md +0 -388
  246. package/example/node/node_modules/mime-types/LICENSE +0 -23
  247. package/example/node/node_modules/mime-types/README.md +0 -113
  248. package/example/node/node_modules/mime-types/index.js +0 -188
  249. package/example/node/node_modules/mime-types/package.json +0 -44
  250. package/example/node/node_modules/ms/index.js +0 -152
  251. package/example/node/node_modules/ms/license.md +0 -21
  252. package/example/node/node_modules/ms/package.json +0 -37
  253. package/example/node/node_modules/ms/readme.md +0 -51
  254. package/example/node/node_modules/negotiator/HISTORY.md +0 -103
  255. package/example/node/node_modules/negotiator/LICENSE +0 -24
  256. package/example/node/node_modules/negotiator/README.md +0 -203
  257. package/example/node/node_modules/negotiator/index.js +0 -124
  258. package/example/node/node_modules/negotiator/lib/charset.js +0 -169
  259. package/example/node/node_modules/negotiator/lib/encoding.js +0 -184
  260. package/example/node/node_modules/negotiator/lib/language.js +0 -179
  261. package/example/node/node_modules/negotiator/lib/mediaType.js +0 -294
  262. package/example/node/node_modules/negotiator/package.json +0 -42
  263. package/example/node/node_modules/on-finished/HISTORY.md +0 -88
  264. package/example/node/node_modules/on-finished/LICENSE +0 -23
  265. package/example/node/node_modules/on-finished/README.md +0 -154
  266. package/example/node/node_modules/on-finished/index.js +0 -196
  267. package/example/node/node_modules/on-finished/package.json +0 -31
  268. package/example/node/node_modules/parseurl/HISTORY.md +0 -58
  269. package/example/node/node_modules/parseurl/LICENSE +0 -24
  270. package/example/node/node_modules/parseurl/README.md +0 -133
  271. package/example/node/node_modules/parseurl/index.js +0 -158
  272. package/example/node/node_modules/parseurl/package.json +0 -40
  273. package/example/node/node_modules/path-to-regexp/History.md +0 -36
  274. package/example/node/node_modules/path-to-regexp/LICENSE +0 -21
  275. package/example/node/node_modules/path-to-regexp/Readme.md +0 -35
  276. package/example/node/node_modules/path-to-regexp/index.js +0 -129
  277. package/example/node/node_modules/path-to-regexp/package.json +0 -30
  278. package/example/node/node_modules/proxy-addr/HISTORY.md +0 -161
  279. package/example/node/node_modules/proxy-addr/LICENSE +0 -22
  280. package/example/node/node_modules/proxy-addr/README.md +0 -139
  281. package/example/node/node_modules/proxy-addr/index.js +0 -327
  282. package/example/node/node_modules/proxy-addr/package.json +0 -47
  283. package/example/node/node_modules/qs/.editorconfig +0 -39
  284. package/example/node/node_modules/qs/.eslintignore +0 -2
  285. package/example/node/node_modules/qs/.eslintrc +0 -35
  286. package/example/node/node_modules/qs/.github/FUNDING.yml +0 -12
  287. package/example/node/node_modules/qs/.nycrc +0 -13
  288. package/example/node/node_modules/qs/CHANGELOG.md +0 -359
  289. package/example/node/node_modules/qs/LICENSE.md +0 -29
  290. package/example/node/node_modules/qs/README.md +0 -604
  291. package/example/node/node_modules/qs/dist/qs.js +0 -832
  292. package/example/node/node_modules/qs/lib/formats.js +0 -23
  293. package/example/node/node_modules/qs/lib/index.js +0 -11
  294. package/example/node/node_modules/qs/lib/parse.js +0 -257
  295. package/example/node/node_modules/qs/lib/stringify.js +0 -278
  296. package/example/node/node_modules/qs/lib/utils.js +0 -251
  297. package/example/node/node_modules/qs/package.json +0 -69
  298. package/example/node/node_modules/qs/test/parse.js +0 -772
  299. package/example/node/node_modules/qs/test/stringify.js +0 -793
  300. package/example/node/node_modules/qs/test/utils.js +0 -136
  301. package/example/node/node_modules/range-parser/HISTORY.md +0 -56
  302. package/example/node/node_modules/range-parser/LICENSE +0 -23
  303. package/example/node/node_modules/range-parser/README.md +0 -84
  304. package/example/node/node_modules/range-parser/index.js +0 -162
  305. package/example/node/node_modules/range-parser/package.json +0 -44
  306. package/example/node/node_modules/raw-body/HISTORY.md +0 -284
  307. package/example/node/node_modules/raw-body/LICENSE +0 -22
  308. package/example/node/node_modules/raw-body/README.md +0 -217
  309. package/example/node/node_modules/raw-body/index.d.ts +0 -87
  310. package/example/node/node_modules/raw-body/index.js +0 -286
  311. package/example/node/node_modules/raw-body/package.json +0 -48
  312. package/example/node/node_modules/safe-buffer/LICENSE +0 -21
  313. package/example/node/node_modules/safe-buffer/README.md +0 -584
  314. package/example/node/node_modules/safe-buffer/index.d.ts +0 -187
  315. package/example/node/node_modules/safe-buffer/index.js +0 -65
  316. package/example/node/node_modules/safe-buffer/package.json +0 -51
  317. package/example/node/node_modules/safer-buffer/LICENSE +0 -21
  318. package/example/node/node_modules/safer-buffer/Porting-Buffer.md +0 -268
  319. package/example/node/node_modules/safer-buffer/Readme.md +0 -156
  320. package/example/node/node_modules/safer-buffer/dangerous.js +0 -58
  321. package/example/node/node_modules/safer-buffer/package.json +0 -34
  322. package/example/node/node_modules/safer-buffer/safer.js +0 -77
  323. package/example/node/node_modules/safer-buffer/tests.js +0 -406
  324. package/example/node/node_modules/send/HISTORY.md +0 -506
  325. package/example/node/node_modules/send/LICENSE +0 -23
  326. package/example/node/node_modules/send/README.md +0 -327
  327. package/example/node/node_modules/send/index.js +0 -1133
  328. package/example/node/node_modules/send/node_modules/.bin/mime +0 -15
  329. package/example/node/node_modules/send/node_modules/.bin/mime.cmd +0 -7
  330. package/example/node/node_modules/send/node_modules/ms/index.js +0 -162
  331. package/example/node/node_modules/send/node_modules/ms/license.md +0 -21
  332. package/example/node/node_modules/send/node_modules/ms/package.json +0 -38
  333. package/example/node/node_modules/send/node_modules/ms/readme.md +0 -59
  334. package/example/node/node_modules/send/package.json +0 -61
  335. package/example/node/node_modules/serve-static/HISTORY.md +0 -459
  336. package/example/node/node_modules/serve-static/LICENSE +0 -25
  337. package/example/node/node_modules/serve-static/README.md +0 -257
  338. package/example/node/node_modules/serve-static/index.js +0 -210
  339. package/example/node/node_modules/serve-static/package.json +0 -42
  340. package/example/node/node_modules/setprototypeof/LICENSE +0 -13
  341. package/example/node/node_modules/setprototypeof/README.md +0 -31
  342. package/example/node/node_modules/setprototypeof/index.d.ts +0 -2
  343. package/example/node/node_modules/setprototypeof/index.js +0 -17
  344. package/example/node/node_modules/setprototypeof/package.json +0 -38
  345. package/example/node/node_modules/setprototypeof/test/index.js +0 -24
  346. package/example/node/node_modules/statuses/HISTORY.md +0 -65
  347. package/example/node/node_modules/statuses/LICENSE +0 -23
  348. package/example/node/node_modules/statuses/README.md +0 -127
  349. package/example/node/node_modules/statuses/codes.json +0 -66
  350. package/example/node/node_modules/statuses/index.js +0 -113
  351. package/example/node/node_modules/statuses/package.json +0 -48
  352. package/example/node/node_modules/toidentifier/HISTORY.md +0 -9
  353. package/example/node/node_modules/toidentifier/LICENSE +0 -21
  354. package/example/node/node_modules/toidentifier/README.md +0 -61
  355. package/example/node/node_modules/toidentifier/index.js +0 -32
  356. package/example/node/node_modules/toidentifier/package.json +0 -38
  357. package/example/node/node_modules/type-is/HISTORY.md +0 -259
  358. package/example/node/node_modules/type-is/LICENSE +0 -23
  359. package/example/node/node_modules/type-is/README.md +0 -170
  360. package/example/node/node_modules/type-is/index.js +0 -266
  361. package/example/node/node_modules/type-is/package.json +0 -45
  362. package/example/node/node_modules/unpipe/HISTORY.md +0 -4
  363. package/example/node/node_modules/unpipe/LICENSE +0 -22
  364. package/example/node/node_modules/unpipe/README.md +0 -43
  365. package/example/node/node_modules/unpipe/index.js +0 -69
  366. package/example/node/node_modules/unpipe/package.json +0 -27
  367. package/example/node/node_modules/utils-merge/LICENSE +0 -20
  368. package/example/node/node_modules/utils-merge/README.md +0 -34
  369. package/example/node/node_modules/utils-merge/index.js +0 -23
  370. package/example/node/node_modules/utils-merge/package.json +0 -40
  371. package/example/node/node_modules/vary/HISTORY.md +0 -39
  372. package/example/node/node_modules/vary/LICENSE +0 -22
  373. package/example/node/node_modules/vary/README.md +0 -101
  374. package/example/node/node_modules/vary/index.js +0 -149
  375. package/example/node/node_modules/vary/package.json +0 -43
  376. package/example/node/server.js +0 -38
  377. package/src/index.js +0 -16
  378. package/src/lib/crawler/provider.js +0 -11
  379. package/src/lib/crawler.js +0 -130
  380. package/test/lib/crawler.test.js +0 -94
  381. package/webpack.common.js +0 -20
  382. package/webpack.dev.js +0 -7
  383. package/webpack.prod.js +0 -14
@@ -1,772 +0,0 @@
1
- 'use strict';
2
-
3
- var test = require('tape');
4
- var qs = require('../');
5
- var utils = require('../lib/utils');
6
- var iconv = require('iconv-lite');
7
- var SaferBuffer = require('safer-buffer').Buffer;
8
-
9
- test('parse()', function (t) {
10
- t.test('parses a simple string', function (st) {
11
- st.deepEqual(qs.parse('0=foo'), { 0: 'foo' });
12
- st.deepEqual(qs.parse('foo=c++'), { foo: 'c ' });
13
- st.deepEqual(qs.parse('a[>=]=23'), { a: { '>=': '23' } });
14
- st.deepEqual(qs.parse('a[<=>]==23'), { a: { '<=>': '=23' } });
15
- st.deepEqual(qs.parse('a[==]=23'), { a: { '==': '23' } });
16
- st.deepEqual(qs.parse('foo', { strictNullHandling: true }), { foo: null });
17
- st.deepEqual(qs.parse('foo'), { foo: '' });
18
- st.deepEqual(qs.parse('foo='), { foo: '' });
19
- st.deepEqual(qs.parse('foo=bar'), { foo: 'bar' });
20
- st.deepEqual(qs.parse(' foo = bar = baz '), { ' foo ': ' bar = baz ' });
21
- st.deepEqual(qs.parse('foo=bar=baz'), { foo: 'bar=baz' });
22
- st.deepEqual(qs.parse('foo=bar&bar=baz'), { foo: 'bar', bar: 'baz' });
23
- st.deepEqual(qs.parse('foo2=bar2&baz2='), { foo2: 'bar2', baz2: '' });
24
- st.deepEqual(qs.parse('foo=bar&baz', { strictNullHandling: true }), { foo: 'bar', baz: null });
25
- st.deepEqual(qs.parse('foo=bar&baz'), { foo: 'bar', baz: '' });
26
- st.deepEqual(qs.parse('cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World'), {
27
- cht: 'p3',
28
- chd: 't:60,40',
29
- chs: '250x100',
30
- chl: 'Hello|World'
31
- });
32
- st.end();
33
- });
34
-
35
- t.test('arrayFormat: brackets allows only explicit arrays', function (st) {
36
- st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] });
37
- st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] });
38
- st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'brackets' }), { a: 'b,c' });
39
- st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'brackets' }), { a: ['b', 'c'] });
40
- st.end();
41
- });
42
-
43
- t.test('arrayFormat: indices allows only indexed arrays', function (st) {
44
- st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] });
45
- st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] });
46
- st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'indices' }), { a: 'b,c' });
47
- st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'indices' }), { a: ['b', 'c'] });
48
- st.end();
49
- });
50
-
51
- t.test('arrayFormat: comma allows only comma-separated arrays', function (st) {
52
- st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] });
53
- st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] });
54
- st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'comma' }), { a: 'b,c' });
55
- st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'comma' }), { a: ['b', 'c'] });
56
- st.end();
57
- });
58
-
59
- t.test('arrayFormat: repeat allows only repeated values', function (st) {
60
- st.deepEqual(qs.parse('a[]=b&a[]=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] });
61
- st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] });
62
- st.deepEqual(qs.parse('a=b,c', { arrayFormat: 'repeat' }), { a: 'b,c' });
63
- st.deepEqual(qs.parse('a=b&a=c', { arrayFormat: 'repeat' }), { a: ['b', 'c'] });
64
- st.end();
65
- });
66
-
67
- t.test('allows enabling dot notation', function (st) {
68
- st.deepEqual(qs.parse('a.b=c'), { 'a.b': 'c' });
69
- st.deepEqual(qs.parse('a.b=c', { allowDots: true }), { a: { b: 'c' } });
70
- st.end();
71
- });
72
-
73
- t.deepEqual(qs.parse('a[b]=c'), { a: { b: 'c' } }, 'parses a single nested string');
74
- t.deepEqual(qs.parse('a[b][c]=d'), { a: { b: { c: 'd' } } }, 'parses a double nested string');
75
- t.deepEqual(
76
- qs.parse('a[b][c][d][e][f][g][h]=i'),
77
- { a: { b: { c: { d: { e: { f: { '[g][h]': 'i' } } } } } } },
78
- 'defaults to a depth of 5'
79
- );
80
-
81
- t.test('only parses one level when depth = 1', function (st) {
82
- st.deepEqual(qs.parse('a[b][c]=d', { depth: 1 }), { a: { b: { '[c]': 'd' } } });
83
- st.deepEqual(qs.parse('a[b][c][d]=e', { depth: 1 }), { a: { b: { '[c][d]': 'e' } } });
84
- st.end();
85
- });
86
-
87
- t.test('uses original key when depth = 0', function (st) {
88
- st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: 0 }), { 'a[0]': 'b', 'a[1]': 'c' });
89
- 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' });
90
- st.end();
91
- });
92
-
93
- t.test('uses original key when depth = false', function (st) {
94
- st.deepEqual(qs.parse('a[0]=b&a[1]=c', { depth: false }), { 'a[0]': 'b', 'a[1]': 'c' });
95
- 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' });
96
- st.end();
97
- });
98
-
99
- t.deepEqual(qs.parse('a=b&a=c'), { a: ['b', 'c'] }, 'parses a simple array');
100
-
101
- t.test('parses an explicit array', function (st) {
102
- st.deepEqual(qs.parse('a[]=b'), { a: ['b'] });
103
- st.deepEqual(qs.parse('a[]=b&a[]=c'), { a: ['b', 'c'] });
104
- st.deepEqual(qs.parse('a[]=b&a[]=c&a[]=d'), { a: ['b', 'c', 'd'] });
105
- st.end();
106
- });
107
-
108
- t.test('parses a mix of simple and explicit arrays', function (st) {
109
- st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] });
110
- st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] });
111
- st.deepEqual(qs.parse('a[0]=b&a=c'), { a: ['b', 'c'] });
112
- st.deepEqual(qs.parse('a=b&a[0]=c'), { a: ['b', 'c'] });
113
-
114
- st.deepEqual(qs.parse('a[1]=b&a=c', { arrayLimit: 20 }), { a: ['b', 'c'] });
115
- st.deepEqual(qs.parse('a[]=b&a=c', { arrayLimit: 0 }), { a: ['b', 'c'] });
116
- st.deepEqual(qs.parse('a[]=b&a=c'), { a: ['b', 'c'] });
117
-
118
- st.deepEqual(qs.parse('a=b&a[1]=c', { arrayLimit: 20 }), { a: ['b', 'c'] });
119
- st.deepEqual(qs.parse('a=b&a[]=c', { arrayLimit: 0 }), { a: ['b', 'c'] });
120
- st.deepEqual(qs.parse('a=b&a[]=c'), { a: ['b', 'c'] });
121
-
122
- st.end();
123
- });
124
-
125
- t.test('parses a nested array', function (st) {
126
- st.deepEqual(qs.parse('a[b][]=c&a[b][]=d'), { a: { b: ['c', 'd'] } });
127
- st.deepEqual(qs.parse('a[>=]=25'), { a: { '>=': '25' } });
128
- st.end();
129
- });
130
-
131
- t.test('allows to specify array indices', function (st) {
132
- st.deepEqual(qs.parse('a[1]=c&a[0]=b&a[2]=d'), { a: ['b', 'c', 'd'] });
133
- st.deepEqual(qs.parse('a[1]=c&a[0]=b'), { a: ['b', 'c'] });
134
- st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 20 }), { a: ['c'] });
135
- st.deepEqual(qs.parse('a[1]=c', { arrayLimit: 0 }), { a: { 1: 'c' } });
136
- st.deepEqual(qs.parse('a[1]=c'), { a: ['c'] });
137
- st.end();
138
- });
139
-
140
- t.test('limits specific array indices to arrayLimit', function (st) {
141
- st.deepEqual(qs.parse('a[20]=a', { arrayLimit: 20 }), { a: ['a'] });
142
- st.deepEqual(qs.parse('a[21]=a', { arrayLimit: 20 }), { a: { 21: 'a' } });
143
- st.end();
144
- });
145
-
146
- t.deepEqual(qs.parse('a[12b]=c'), { a: { '12b': 'c' } }, 'supports keys that begin with a number');
147
-
148
- t.test('supports encoded = signs', function (st) {
149
- st.deepEqual(qs.parse('he%3Dllo=th%3Dere'), { 'he=llo': 'th=ere' });
150
- st.end();
151
- });
152
-
153
- t.test('is ok with url encoded strings', function (st) {
154
- st.deepEqual(qs.parse('a[b%20c]=d'), { a: { 'b c': 'd' } });
155
- st.deepEqual(qs.parse('a[b]=c%20d'), { a: { b: 'c d' } });
156
- st.end();
157
- });
158
-
159
- t.test('allows brackets in the value', function (st) {
160
- st.deepEqual(qs.parse('pets=["tobi"]'), { pets: '["tobi"]' });
161
- st.deepEqual(qs.parse('operators=[">=", "<="]'), { operators: '[">=", "<="]' });
162
- st.end();
163
- });
164
-
165
- t.test('allows empty values', function (st) {
166
- st.deepEqual(qs.parse(''), {});
167
- st.deepEqual(qs.parse(null), {});
168
- st.deepEqual(qs.parse(undefined), {});
169
- st.end();
170
- });
171
-
172
- t.test('transforms arrays to objects', function (st) {
173
- st.deepEqual(qs.parse('foo[0]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } });
174
- st.deepEqual(qs.parse('foo[bad]=baz&foo[0]=bar'), { foo: { bad: 'baz', 0: 'bar' } });
175
- st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar'), { foo: { bad: 'baz', 0: 'bar' } });
176
- st.deepEqual(qs.parse('foo[]=bar&foo[bad]=baz'), { foo: { 0: 'bar', bad: 'baz' } });
177
- st.deepEqual(qs.parse('foo[bad]=baz&foo[]=bar&foo[]=foo'), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
178
- 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' }] });
179
-
180
- st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: false }), { a: { 0: 'b', t: 'u' } });
181
- st.deepEqual(qs.parse('a[]=b&a[t]=u&a[hasOwnProperty]=c', { allowPrototypes: true }), { a: { 0: 'b', t: 'u', hasOwnProperty: 'c' } });
182
- st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: false }), { a: { 0: 'b', x: 'y' } });
183
- st.deepEqual(qs.parse('a[]=b&a[hasOwnProperty]=c&a[x]=y', { allowPrototypes: true }), { a: { 0: 'b', hasOwnProperty: 'c', x: 'y' } });
184
- st.end();
185
- });
186
-
187
- t.test('transforms arrays to objects (dot notation)', function (st) {
188
- st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: 'baz' } });
189
- st.deepEqual(qs.parse('foo[0].baz=bar&fool.bad.boo=baz', { allowDots: true }), { foo: [{ baz: 'bar' }], fool: { bad: { boo: 'baz' } } });
190
- st.deepEqual(qs.parse('foo[0][0].baz=bar&fool.bad=baz', { allowDots: true }), { foo: [[{ baz: 'bar' }]], fool: { bad: 'baz' } });
191
- st.deepEqual(qs.parse('foo[0].baz[0]=15&foo[0].bar=2', { allowDots: true }), { foo: [{ baz: ['15'], bar: '2' }] });
192
- 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' }] });
193
- st.deepEqual(qs.parse('foo.bad=baz&foo[0]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } });
194
- st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar' } });
195
- st.deepEqual(qs.parse('foo[]=bar&foo.bad=baz', { allowDots: true }), { foo: { 0: 'bar', bad: 'baz' } });
196
- st.deepEqual(qs.parse('foo.bad=baz&foo[]=bar&foo[]=foo', { allowDots: true }), { foo: { bad: 'baz', 0: 'bar', 1: 'foo' } });
197
- 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' }] });
198
- st.end();
199
- });
200
-
201
- t.test('correctly prunes undefined values when converting an array to an object', function (st) {
202
- st.deepEqual(qs.parse('a[2]=b&a[99999999]=c'), { a: { 2: 'b', 99999999: 'c' } });
203
- st.end();
204
- });
205
-
206
- t.test('supports malformed uri characters', function (st) {
207
- st.deepEqual(qs.parse('{%:%}', { strictNullHandling: true }), { '{%:%}': null });
208
- st.deepEqual(qs.parse('{%:%}='), { '{%:%}': '' });
209
- st.deepEqual(qs.parse('foo=%:%}'), { foo: '%:%}' });
210
- st.end();
211
- });
212
-
213
- t.test('doesn\'t produce empty keys', function (st) {
214
- st.deepEqual(qs.parse('_r=1&'), { _r: '1' });
215
- st.end();
216
- });
217
-
218
- t.test('cannot access Object prototype', function (st) {
219
- qs.parse('constructor[prototype][bad]=bad');
220
- qs.parse('bad[constructor][prototype][bad]=bad');
221
- st.equal(typeof Object.prototype.bad, 'undefined');
222
- st.end();
223
- });
224
-
225
- t.test('parses arrays of objects', function (st) {
226
- st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] });
227
- st.deepEqual(qs.parse('a[0][b]=c'), { a: [{ b: 'c' }] });
228
- st.end();
229
- });
230
-
231
- t.test('allows for empty strings in arrays', function (st) {
232
- st.deepEqual(qs.parse('a[]=b&a[]=&a[]=c'), { a: ['b', '', 'c'] });
233
-
234
- st.deepEqual(
235
- qs.parse('a[0]=b&a[1]&a[2]=c&a[19]=', { strictNullHandling: true, arrayLimit: 20 }),
236
- { a: ['b', null, 'c', ''] },
237
- 'with arrayLimit 20 + array indices: null then empty string works'
238
- );
239
- st.deepEqual(
240
- qs.parse('a[]=b&a[]&a[]=c&a[]=', { strictNullHandling: true, arrayLimit: 0 }),
241
- { a: ['b', null, 'c', ''] },
242
- 'with arrayLimit 0 + array brackets: null then empty string works'
243
- );
244
-
245
- st.deepEqual(
246
- qs.parse('a[0]=b&a[1]=&a[2]=c&a[19]', { strictNullHandling: true, arrayLimit: 20 }),
247
- { a: ['b', '', 'c', null] },
248
- 'with arrayLimit 20 + array indices: empty string then null works'
249
- );
250
- st.deepEqual(
251
- qs.parse('a[]=b&a[]=&a[]=c&a[]', { strictNullHandling: true, arrayLimit: 0 }),
252
- { a: ['b', '', 'c', null] },
253
- 'with arrayLimit 0 + array brackets: empty string then null works'
254
- );
255
-
256
- st.deepEqual(
257
- qs.parse('a[]=&a[]=b&a[]=c'),
258
- { a: ['', 'b', 'c'] },
259
- 'array brackets: empty strings work'
260
- );
261
- st.end();
262
- });
263
-
264
- t.test('compacts sparse arrays', function (st) {
265
- st.deepEqual(qs.parse('a[10]=1&a[2]=2', { arrayLimit: 20 }), { a: ['2', '1'] });
266
- st.deepEqual(qs.parse('a[1][b][2][c]=1', { arrayLimit: 20 }), { a: [{ b: [{ c: '1' }] }] });
267
- st.deepEqual(qs.parse('a[1][2][3][c]=1', { arrayLimit: 20 }), { a: [[[{ c: '1' }]]] });
268
- st.deepEqual(qs.parse('a[1][2][3][c][1]=1', { arrayLimit: 20 }), { a: [[[{ c: ['1'] }]]] });
269
- st.end();
270
- });
271
-
272
- t.test('parses semi-parsed strings', function (st) {
273
- st.deepEqual(qs.parse({ 'a[b]': 'c' }), { a: { b: 'c' } });
274
- st.deepEqual(qs.parse({ 'a[b]': 'c', 'a[d]': 'e' }), { a: { b: 'c', d: 'e' } });
275
- st.end();
276
- });
277
-
278
- t.test('parses buffers correctly', function (st) {
279
- var b = SaferBuffer.from('test');
280
- st.deepEqual(qs.parse({ a: b }), { a: b });
281
- st.end();
282
- });
283
-
284
- t.test('parses jquery-param strings', function (st) {
285
- // readable = 'filter[0][]=int1&filter[0][]==&filter[0][]=77&filter[]=and&filter[2][]=int2&filter[2][]==&filter[2][]=8'
286
- 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';
287
- var expected = { filter: [['int1', '=', '77'], 'and', ['int2', '=', '8']] };
288
- st.deepEqual(qs.parse(encoded), expected);
289
- st.end();
290
- });
291
-
292
- t.test('continues parsing when no parent is found', function (st) {
293
- st.deepEqual(qs.parse('[]=&a=b'), { 0: '', a: 'b' });
294
- st.deepEqual(qs.parse('[]&a=b', { strictNullHandling: true }), { 0: null, a: 'b' });
295
- st.deepEqual(qs.parse('[foo]=bar'), { foo: 'bar' });
296
- st.end();
297
- });
298
-
299
- t.test('does not error when parsing a very long array', function (st) {
300
- var str = 'a[]=a';
301
- while (Buffer.byteLength(str) < 128 * 1024) {
302
- str = str + '&' + str;
303
- }
304
-
305
- st.doesNotThrow(function () {
306
- qs.parse(str);
307
- });
308
-
309
- st.end();
310
- });
311
-
312
- t.test('should not throw when a native prototype has an enumerable property', function (st) {
313
- Object.prototype.crash = '';
314
- Array.prototype.crash = '';
315
- st.doesNotThrow(qs.parse.bind(null, 'a=b'));
316
- st.deepEqual(qs.parse('a=b'), { a: 'b' });
317
- st.doesNotThrow(qs.parse.bind(null, 'a[][b]=c'));
318
- st.deepEqual(qs.parse('a[][b]=c'), { a: [{ b: 'c' }] });
319
- delete Object.prototype.crash;
320
- delete Array.prototype.crash;
321
- st.end();
322
- });
323
-
324
- t.test('parses a string with an alternative string delimiter', function (st) {
325
- st.deepEqual(qs.parse('a=b;c=d', { delimiter: ';' }), { a: 'b', c: 'd' });
326
- st.end();
327
- });
328
-
329
- t.test('parses a string with an alternative RegExp delimiter', function (st) {
330
- st.deepEqual(qs.parse('a=b; c=d', { delimiter: /[;,] */ }), { a: 'b', c: 'd' });
331
- st.end();
332
- });
333
-
334
- t.test('does not use non-splittable objects as delimiters', function (st) {
335
- st.deepEqual(qs.parse('a=b&c=d', { delimiter: true }), { a: 'b', c: 'd' });
336
- st.end();
337
- });
338
-
339
- t.test('allows overriding parameter limit', function (st) {
340
- st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: 1 }), { a: 'b' });
341
- st.end();
342
- });
343
-
344
- t.test('allows setting the parameter limit to Infinity', function (st) {
345
- st.deepEqual(qs.parse('a=b&c=d', { parameterLimit: Infinity }), { a: 'b', c: 'd' });
346
- st.end();
347
- });
348
-
349
- t.test('allows overriding array limit', function (st) {
350
- st.deepEqual(qs.parse('a[0]=b', { arrayLimit: -1 }), { a: { 0: 'b' } });
351
- st.deepEqual(qs.parse('a[-1]=b', { arrayLimit: -1 }), { a: { '-1': 'b' } });
352
- st.deepEqual(qs.parse('a[0]=b&a[1]=c', { arrayLimit: 0 }), { a: { 0: 'b', 1: 'c' } });
353
- st.end();
354
- });
355
-
356
- t.test('allows disabling array parsing', function (st) {
357
- var indices = qs.parse('a[0]=b&a[1]=c', { parseArrays: false });
358
- st.deepEqual(indices, { a: { 0: 'b', 1: 'c' } });
359
- st.equal(Array.isArray(indices.a), false, 'parseArrays:false, indices case is not an array');
360
-
361
- var emptyBrackets = qs.parse('a[]=b', { parseArrays: false });
362
- st.deepEqual(emptyBrackets, { a: { 0: 'b' } });
363
- st.equal(Array.isArray(emptyBrackets.a), false, 'parseArrays:false, empty brackets case is not an array');
364
-
365
- st.end();
366
- });
367
-
368
- t.test('allows for query string prefix', function (st) {
369
- st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
370
- st.deepEqual(qs.parse('foo=bar', { ignoreQueryPrefix: true }), { foo: 'bar' });
371
- st.deepEqual(qs.parse('?foo=bar', { ignoreQueryPrefix: false }), { '?foo': 'bar' });
372
- st.end();
373
- });
374
-
375
- t.test('parses an object', function (st) {
376
- var input = {
377
- 'user[name]': { 'pop[bob]': 3 },
378
- 'user[email]': null
379
- };
380
-
381
- var expected = {
382
- user: {
383
- name: { 'pop[bob]': 3 },
384
- email: null
385
- }
386
- };
387
-
388
- var result = qs.parse(input);
389
-
390
- st.deepEqual(result, expected);
391
- st.end();
392
- });
393
-
394
- t.test('parses string with comma as array divider', function (st) {
395
- st.deepEqual(qs.parse('foo=bar,tee', { comma: true }), { foo: ['bar', 'tee'] });
396
- st.deepEqual(qs.parse('foo[bar]=coffee,tee', { comma: true }), { foo: { bar: ['coffee', 'tee'] } });
397
- st.deepEqual(qs.parse('foo=', { comma: true }), { foo: '' });
398
- st.deepEqual(qs.parse('foo', { comma: true }), { foo: '' });
399
- st.deepEqual(qs.parse('foo', { comma: true, strictNullHandling: true }), { foo: null });
400
- st.end();
401
- });
402
-
403
- t.test('parses values with comma as array divider', function (st) {
404
- st.deepEqual(qs.parse({ foo: 'bar,tee' }, { comma: false }), { foo: 'bar,tee' });
405
- st.deepEqual(qs.parse({ foo: 'bar,tee' }, { comma: true }), { foo: ['bar', 'tee'] });
406
- st.end();
407
- });
408
-
409
- t.test('use number decoder, parses string that has one number with comma option enabled', function (st) {
410
- var decoder = function (str, defaultDecoder, charset, type) {
411
- if (!isNaN(Number(str))) {
412
- return parseFloat(str);
413
- }
414
- return defaultDecoder(str, defaultDecoder, charset, type);
415
- };
416
-
417
- st.deepEqual(qs.parse('foo=1', { comma: true, decoder: decoder }), { foo: 1 });
418
- st.deepEqual(qs.parse('foo=0', { comma: true, decoder: decoder }), { foo: 0 });
419
-
420
- st.end();
421
- });
422
-
423
- t.test('parses brackets holds array of arrays when having two parts of strings with comma as array divider', function (st) {
424
- st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=4,5,6', { comma: true }), { foo: [['1', '2', '3'], ['4', '5', '6']] });
425
- st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=', { comma: true }), { foo: [['1', '2', '3'], ''] });
426
- st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=,', { comma: true }), { foo: [['1', '2', '3'], ['', '']] });
427
- st.deepEqual(qs.parse('foo[]=1,2,3&foo[]=a', { comma: true }), { foo: [['1', '2', '3'], 'a'] });
428
-
429
- st.end();
430
- });
431
-
432
- t.test('parses comma delimited array while having percent-encoded comma treated as normal text', function (st) {
433
- st.deepEqual(qs.parse('foo=a%2Cb', { comma: true }), { foo: 'a,b' });
434
- st.deepEqual(qs.parse('foo=a%2C%20b,d', { comma: true }), { foo: ['a, b', 'd'] });
435
- st.deepEqual(qs.parse('foo=a%2C%20b,c%2C%20d', { comma: true }), { foo: ['a, b', 'c, d'] });
436
-
437
- st.end();
438
- });
439
-
440
- t.test('parses an object in dot notation', function (st) {
441
- var input = {
442
- 'user.name': { 'pop[bob]': 3 },
443
- 'user.email.': null
444
- };
445
-
446
- var expected = {
447
- user: {
448
- name: { 'pop[bob]': 3 },
449
- email: null
450
- }
451
- };
452
-
453
- var result = qs.parse(input, { allowDots: true });
454
-
455
- st.deepEqual(result, expected);
456
- st.end();
457
- });
458
-
459
- t.test('parses an object and not child values', function (st) {
460
- var input = {
461
- 'user[name]': { 'pop[bob]': { test: 3 } },
462
- 'user[email]': null
463
- };
464
-
465
- var expected = {
466
- user: {
467
- name: { 'pop[bob]': { test: 3 } },
468
- email: null
469
- }
470
- };
471
-
472
- var result = qs.parse(input);
473
-
474
- st.deepEqual(result, expected);
475
- st.end();
476
- });
477
-
478
- t.test('does not blow up when Buffer global is missing', function (st) {
479
- var tempBuffer = global.Buffer;
480
- delete global.Buffer;
481
- var result = qs.parse('a=b&c=d');
482
- global.Buffer = tempBuffer;
483
- st.deepEqual(result, { a: 'b', c: 'd' });
484
- st.end();
485
- });
486
-
487
- t.test('does not crash when parsing circular references', function (st) {
488
- var a = {};
489
- a.b = a;
490
-
491
- var parsed;
492
-
493
- st.doesNotThrow(function () {
494
- parsed = qs.parse({ 'foo[bar]': 'baz', 'foo[baz]': a });
495
- });
496
-
497
- st.equal('foo' in parsed, true, 'parsed has "foo" property');
498
- st.equal('bar' in parsed.foo, true);
499
- st.equal('baz' in parsed.foo, true);
500
- st.equal(parsed.foo.bar, 'baz');
501
- st.deepEqual(parsed.foo.baz, a);
502
- st.end();
503
- });
504
-
505
- t.test('does not crash when parsing deep objects', function (st) {
506
- var parsed;
507
- var str = 'foo';
508
-
509
- for (var i = 0; i < 5000; i++) {
510
- str += '[p]';
511
- }
512
-
513
- str += '=bar';
514
-
515
- st.doesNotThrow(function () {
516
- parsed = qs.parse(str, { depth: 5000 });
517
- });
518
-
519
- st.equal('foo' in parsed, true, 'parsed has "foo" property');
520
-
521
- var depth = 0;
522
- var ref = parsed.foo;
523
- while ((ref = ref.p)) {
524
- depth += 1;
525
- }
526
-
527
- st.equal(depth, 5000, 'parsed is 5000 properties deep');
528
-
529
- st.end();
530
- });
531
-
532
- t.test('parses null objects correctly', { skip: !Object.create }, function (st) {
533
- var a = Object.create(null);
534
- a.b = 'c';
535
-
536
- st.deepEqual(qs.parse(a), { b: 'c' });
537
- var result = qs.parse({ a: a });
538
- st.equal('a' in result, true, 'result has "a" property');
539
- st.deepEqual(result.a, a);
540
- st.end();
541
- });
542
-
543
- t.test('parses dates correctly', function (st) {
544
- var now = new Date();
545
- st.deepEqual(qs.parse({ a: now }), { a: now });
546
- st.end();
547
- });
548
-
549
- t.test('parses regular expressions correctly', function (st) {
550
- var re = /^test$/;
551
- st.deepEqual(qs.parse({ a: re }), { a: re });
552
- st.end();
553
- });
554
-
555
- t.test('does not allow overwriting prototype properties', function (st) {
556
- st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: false }), {});
557
- st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: false }), {});
558
-
559
- st.deepEqual(
560
- qs.parse('toString', { allowPrototypes: false }),
561
- {},
562
- 'bare "toString" results in {}'
563
- );
564
-
565
- st.end();
566
- });
567
-
568
- t.test('can allow overwriting prototype properties', function (st) {
569
- st.deepEqual(qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }), { a: { hasOwnProperty: 'b' } });
570
- st.deepEqual(qs.parse('hasOwnProperty=b', { allowPrototypes: true }), { hasOwnProperty: 'b' });
571
-
572
- st.deepEqual(
573
- qs.parse('toString', { allowPrototypes: true }),
574
- { toString: '' },
575
- 'bare "toString" results in { toString: "" }'
576
- );
577
-
578
- st.end();
579
- });
580
-
581
- t.test('params starting with a closing bracket', function (st) {
582
- st.deepEqual(qs.parse(']=toString'), { ']': 'toString' });
583
- st.deepEqual(qs.parse(']]=toString'), { ']]': 'toString' });
584
- st.deepEqual(qs.parse(']hello]=toString'), { ']hello]': 'toString' });
585
- st.end();
586
- });
587
-
588
- t.test('params starting with a starting bracket', function (st) {
589
- st.deepEqual(qs.parse('[=toString'), { '[': 'toString' });
590
- st.deepEqual(qs.parse('[[=toString'), { '[[': 'toString' });
591
- st.deepEqual(qs.parse('[hello[=toString'), { '[hello[': 'toString' });
592
- st.end();
593
- });
594
-
595
- t.test('add keys to objects', function (st) {
596
- st.deepEqual(
597
- qs.parse('a[b]=c&a=d'),
598
- { a: { b: 'c', d: true } },
599
- 'can add keys to objects'
600
- );
601
-
602
- st.deepEqual(
603
- qs.parse('a[b]=c&a=toString'),
604
- { a: { b: 'c' } },
605
- 'can not overwrite prototype'
606
- );
607
-
608
- st.deepEqual(
609
- qs.parse('a[b]=c&a=toString', { allowPrototypes: true }),
610
- { a: { b: 'c', toString: true } },
611
- 'can overwrite prototype with allowPrototypes true'
612
- );
613
-
614
- st.deepEqual(
615
- qs.parse('a[b]=c&a=toString', { plainObjects: true }),
616
- { __proto__: null, a: { __proto__: null, b: 'c', toString: true } },
617
- 'can overwrite prototype with plainObjects true'
618
- );
619
-
620
- st.end();
621
- });
622
-
623
- t.test('can return null objects', { skip: !Object.create }, function (st) {
624
- var expected = Object.create(null);
625
- expected.a = Object.create(null);
626
- expected.a.b = 'c';
627
- expected.a.hasOwnProperty = 'd';
628
- st.deepEqual(qs.parse('a[b]=c&a[hasOwnProperty]=d', { plainObjects: true }), expected);
629
- st.deepEqual(qs.parse(null, { plainObjects: true }), Object.create(null));
630
- var expectedArray = Object.create(null);
631
- expectedArray.a = Object.create(null);
632
- expectedArray.a[0] = 'b';
633
- expectedArray.a.c = 'd';
634
- st.deepEqual(qs.parse('a[]=b&a[c]=d', { plainObjects: true }), expectedArray);
635
- st.end();
636
- });
637
-
638
- t.test('can parse with custom encoding', function (st) {
639
- st.deepEqual(qs.parse('%8c%a7=%91%e5%8d%e3%95%7b', {
640
- decoder: function (str) {
641
- var reg = /%([0-9A-F]{2})/ig;
642
- var result = [];
643
- var parts = reg.exec(str);
644
- while (parts) {
645
- result.push(parseInt(parts[1], 16));
646
- parts = reg.exec(str);
647
- }
648
- return String(iconv.decode(SaferBuffer.from(result), 'shift_jis'));
649
- }
650
- }), { 県: '大阪府' });
651
- st.end();
652
- });
653
-
654
- t.test('receives the default decoder as a second argument', function (st) {
655
- st.plan(1);
656
- qs.parse('a', {
657
- decoder: function (str, defaultDecoder) {
658
- st.equal(defaultDecoder, utils.decode);
659
- }
660
- });
661
- st.end();
662
- });
663
-
664
- t.test('throws error with wrong decoder', function (st) {
665
- st['throws'](function () {
666
- qs.parse({}, { decoder: 'string' });
667
- }, new TypeError('Decoder has to be a function.'));
668
- st.end();
669
- });
670
-
671
- t.test('does not mutate the options argument', function (st) {
672
- var options = {};
673
- qs.parse('a[b]=true', options);
674
- st.deepEqual(options, {});
675
- st.end();
676
- });
677
-
678
- t.test('throws if an invalid charset is specified', function (st) {
679
- st['throws'](function () {
680
- qs.parse('a=b', { charset: 'foobar' });
681
- }, new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'));
682
- st.end();
683
- });
684
-
685
- t.test('parses an iso-8859-1 string if asked to', function (st) {
686
- st.deepEqual(qs.parse('%A2=%BD', { charset: 'iso-8859-1' }), { '¢': '½' });
687
- st.end();
688
- });
689
-
690
- var urlEncodedCheckmarkInUtf8 = '%E2%9C%93';
691
- var urlEncodedOSlashInUtf8 = '%C3%B8';
692
- var urlEncodedNumCheckmark = '%26%2310003%3B';
693
- var urlEncodedNumSmiley = '%26%239786%3B';
694
-
695
- t.test('prefers an utf-8 charset specified by the utf8 sentinel to a default charset of iso-8859-1', function (st) {
696
- st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'iso-8859-1' }), { ø: 'ø' });
697
- st.end();
698
- });
699
-
700
- t.test('prefers an iso-8859-1 charset specified by the utf8 sentinel to a default charset of utf-8', function (st) {
701
- st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { 'ø': 'ø' });
702
- st.end();
703
- });
704
-
705
- t.test('does not require the utf8 sentinel to be defined before the parameters whose decoding it affects', function (st) {
706
- st.deepEqual(qs.parse('a=' + urlEncodedOSlashInUtf8 + '&utf8=' + urlEncodedNumCheckmark, { charsetSentinel: true, charset: 'utf-8' }), { a: 'ø' });
707
- st.end();
708
- });
709
-
710
- t.test('should ignore an utf8 sentinel with an unknown value', function (st) {
711
- st.deepEqual(qs.parse('utf8=foo&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true, charset: 'utf-8' }), { ø: 'ø' });
712
- st.end();
713
- });
714
-
715
- t.test('uses the utf8 sentinel to switch to utf-8 when no default charset is given', function (st) {
716
- st.deepEqual(qs.parse('utf8=' + urlEncodedCheckmarkInUtf8 + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { ø: 'ø' });
717
- st.end();
718
- });
719
-
720
- t.test('uses the utf8 sentinel to switch to iso-8859-1 when no default charset is given', function (st) {
721
- st.deepEqual(qs.parse('utf8=' + urlEncodedNumCheckmark + '&' + urlEncodedOSlashInUtf8 + '=' + urlEncodedOSlashInUtf8, { charsetSentinel: true }), { 'ø': 'ø' });
722
- st.end();
723
- });
724
-
725
- t.test('interprets numeric entities in iso-8859-1 when `interpretNumericEntities`', function (st) {
726
- st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1', interpretNumericEntities: true }), { foo: '☺' });
727
- st.end();
728
- });
729
-
730
- t.test('handles a custom decoder returning `null`, in the `iso-8859-1` charset, when `interpretNumericEntities`', function (st) {
731
- st.deepEqual(qs.parse('foo=&bar=' + urlEncodedNumSmiley, {
732
- charset: 'iso-8859-1',
733
- decoder: function (str, defaultDecoder, charset) {
734
- return str ? defaultDecoder(str, defaultDecoder, charset) : null;
735
- },
736
- interpretNumericEntities: true
737
- }), { foo: null, bar: '☺' });
738
- st.end();
739
- });
740
-
741
- t.test('does not interpret numeric entities in iso-8859-1 when `interpretNumericEntities` is absent', function (st) {
742
- st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'iso-8859-1' }), { foo: '&#9786;' });
743
- st.end();
744
- });
745
-
746
- t.test('does not interpret numeric entities when the charset is utf-8, even when `interpretNumericEntities`', function (st) {
747
- st.deepEqual(qs.parse('foo=' + urlEncodedNumSmiley, { charset: 'utf-8', interpretNumericEntities: true }), { foo: '&#9786;' });
748
- st.end();
749
- });
750
-
751
- t.test('does not interpret %uXXXX syntax in iso-8859-1 mode', function (st) {
752
- st.deepEqual(qs.parse('%u263A=%u263A', { charset: 'iso-8859-1' }), { '%u263A': '%u263A' });
753
- st.end();
754
- });
755
-
756
- t.test('allows for decoding keys and values differently', function (st) {
757
- var decoder = function (str, defaultDecoder, charset, type) {
758
- if (type === 'key') {
759
- return defaultDecoder(str, defaultDecoder, charset, type).toLowerCase();
760
- }
761
- if (type === 'value') {
762
- return defaultDecoder(str, defaultDecoder, charset, type).toUpperCase();
763
- }
764
- throw 'this should never happen! type: ' + type;
765
- };
766
-
767
- st.deepEqual(qs.parse('KeY=vAlUe', { decoder: decoder }), { key: 'VALUE' });
768
- st.end();
769
- });
770
-
771
- t.end();
772
- });