@comapeo/map-server 1.0.0-pre.0 → 1.0.0-pre.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 (146) hide show
  1. package/dist/context.d.ts +1 -1
  2. package/dist/context.js +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/lib/map-share.js +1 -1
  7. package/dist/routes/maps.js +1 -1
  8. package/dist/types.d.ts +5 -5
  9. package/dist/types.js +2 -2
  10. package/node_modules/@fastify/busboy/LICENSE +24 -0
  11. package/node_modules/@fastify/busboy/README.md +270 -0
  12. package/node_modules/@fastify/busboy/deps/dicer/LICENSE +19 -0
  13. package/node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js +213 -0
  14. package/node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js +100 -0
  15. package/node_modules/@fastify/busboy/deps/dicer/lib/PartStream.js +13 -0
  16. package/node_modules/@fastify/busboy/deps/dicer/lib/dicer.d.ts +164 -0
  17. package/node_modules/@fastify/busboy/deps/streamsearch/sbmh.js +230 -0
  18. package/node_modules/@fastify/busboy/lib/main.d.ts +196 -0
  19. package/node_modules/@fastify/busboy/lib/main.js +85 -0
  20. package/node_modules/@fastify/busboy/lib/types/multipart.js +306 -0
  21. package/node_modules/@fastify/busboy/lib/types/urlencoded.js +190 -0
  22. package/node_modules/@fastify/busboy/lib/utils/Decoder.js +54 -0
  23. package/node_modules/@fastify/busboy/lib/utils/basename.js +14 -0
  24. package/node_modules/@fastify/busboy/lib/utils/decodeText.js +114 -0
  25. package/node_modules/@fastify/busboy/lib/utils/getLimit.js +16 -0
  26. package/node_modules/@fastify/busboy/lib/utils/parseParams.js +201 -0
  27. package/node_modules/@fastify/busboy/package.json +81 -0
  28. package/node_modules/@whatwg-node/fetch/CHANGELOG.md +941 -0
  29. package/node_modules/@whatwg-node/fetch/README.md +141 -0
  30. package/node_modules/@whatwg-node/fetch/dist/create-node-ponyfill.js +100 -0
  31. package/node_modules/@whatwg-node/fetch/dist/esm-ponyfill.js +71 -0
  32. package/node_modules/@whatwg-node/fetch/dist/global-ponyfill.js +22 -0
  33. package/node_modules/@whatwg-node/fetch/dist/index.d.ts +73 -0
  34. package/node_modules/@whatwg-node/fetch/dist/node-ponyfill.js +35 -0
  35. package/node_modules/@whatwg-node/fetch/dist/shouldSkipPonyfill.js +17 -0
  36. package/node_modules/@whatwg-node/fetch/package.json +31 -0
  37. package/node_modules/@whatwg-node/node-fetch/cjs/AbortError.js +19 -0
  38. package/node_modules/@whatwg-node/node-fetch/cjs/Blob.js +291 -0
  39. package/node_modules/@whatwg-node/node-fetch/cjs/Body.js +529 -0
  40. package/node_modules/@whatwg-node/node-fetch/cjs/CompressionStream.js +34 -0
  41. package/node_modules/@whatwg-node/node-fetch/cjs/DecompressionStream.js +34 -0
  42. package/node_modules/@whatwg-node/node-fetch/cjs/File.js +15 -0
  43. package/node_modules/@whatwg-node/node-fetch/cjs/FormData.js +150 -0
  44. package/node_modules/@whatwg-node/node-fetch/cjs/Headers.js +309 -0
  45. package/node_modules/@whatwg-node/node-fetch/cjs/IteratorObject.js +134 -0
  46. package/node_modules/@whatwg-node/node-fetch/cjs/ReadableStream.js +245 -0
  47. package/node_modules/@whatwg-node/node-fetch/cjs/Request.js +128 -0
  48. package/node_modules/@whatwg-node/node-fetch/cjs/Response.js +108 -0
  49. package/node_modules/@whatwg-node/node-fetch/cjs/TextEncoderDecoder.js +49 -0
  50. package/node_modules/@whatwg-node/node-fetch/cjs/TextEncoderDecoderStream.js +40 -0
  51. package/node_modules/@whatwg-node/node-fetch/cjs/TransformStream.js +79 -0
  52. package/node_modules/@whatwg-node/node-fetch/cjs/URL.js +28 -0
  53. package/node_modules/@whatwg-node/node-fetch/cjs/URLSearchParams.js +4 -0
  54. package/node_modules/@whatwg-node/node-fetch/cjs/WritableStream.js +115 -0
  55. package/node_modules/@whatwg-node/node-fetch/cjs/fetch.js +107 -0
  56. package/node_modules/@whatwg-node/node-fetch/cjs/fetchCurl.js +142 -0
  57. package/node_modules/@whatwg-node/node-fetch/cjs/fetchNodeHttp.js +152 -0
  58. package/node_modules/@whatwg-node/node-fetch/cjs/index.js +42 -0
  59. package/node_modules/@whatwg-node/node-fetch/cjs/package.json +1 -0
  60. package/node_modules/@whatwg-node/node-fetch/cjs/utils.js +125 -0
  61. package/node_modules/@whatwg-node/node-fetch/esm/AbortError.js +15 -0
  62. package/node_modules/@whatwg-node/node-fetch/esm/Blob.js +279 -0
  63. package/node_modules/@whatwg-node/node-fetch/esm/Body.js +525 -0
  64. package/node_modules/@whatwg-node/node-fetch/esm/CompressionStream.js +29 -0
  65. package/node_modules/@whatwg-node/node-fetch/esm/DecompressionStream.js +29 -0
  66. package/node_modules/@whatwg-node/node-fetch/esm/File.js +11 -0
  67. package/node_modules/@whatwg-node/node-fetch/esm/FormData.js +145 -0
  68. package/node_modules/@whatwg-node/node-fetch/esm/Headers.js +304 -0
  69. package/node_modules/@whatwg-node/node-fetch/esm/IteratorObject.js +130 -0
  70. package/node_modules/@whatwg-node/node-fetch/esm/ReadableStream.js +241 -0
  71. package/node_modules/@whatwg-node/node-fetch/esm/Request.js +124 -0
  72. package/node_modules/@whatwg-node/node-fetch/esm/Response.js +104 -0
  73. package/node_modules/@whatwg-node/node-fetch/esm/TextEncoderDecoder.js +43 -0
  74. package/node_modules/@whatwg-node/node-fetch/esm/TextEncoderDecoderStream.js +35 -0
  75. package/node_modules/@whatwg-node/node-fetch/esm/TransformStream.js +75 -0
  76. package/node_modules/@whatwg-node/node-fetch/esm/URL.js +24 -0
  77. package/node_modules/@whatwg-node/node-fetch/esm/URLSearchParams.js +1 -0
  78. package/node_modules/@whatwg-node/node-fetch/esm/WritableStream.js +111 -0
  79. package/node_modules/@whatwg-node/node-fetch/esm/fetch.js +104 -0
  80. package/node_modules/@whatwg-node/node-fetch/esm/fetchCurl.js +139 -0
  81. package/node_modules/@whatwg-node/node-fetch/esm/fetchNodeHttp.js +148 -0
  82. package/node_modules/@whatwg-node/node-fetch/esm/index.js +18 -0
  83. package/node_modules/@whatwg-node/node-fetch/esm/utils.js +110 -0
  84. package/node_modules/@whatwg-node/node-fetch/package.json +46 -0
  85. package/node_modules/@whatwg-node/node-fetch/typings/AbortError.d.cts +4 -0
  86. package/node_modules/@whatwg-node/node-fetch/typings/AbortError.d.ts +4 -0
  87. package/node_modules/@whatwg-node/node-fetch/typings/Blob.d.cts +63 -0
  88. package/node_modules/@whatwg-node/node-fetch/typings/Blob.d.ts +63 -0
  89. package/node_modules/@whatwg-node/node-fetch/typings/Body.d.cts +54 -0
  90. package/node_modules/@whatwg-node/node-fetch/typings/Body.d.ts +54 -0
  91. package/node_modules/@whatwg-node/node-fetch/typings/CompressionStream.d.cts +6 -0
  92. package/node_modules/@whatwg-node/node-fetch/typings/CompressionStream.d.ts +6 -0
  93. package/node_modules/@whatwg-node/node-fetch/typings/DecompressionStream.d.cts +6 -0
  94. package/node_modules/@whatwg-node/node-fetch/typings/DecompressionStream.d.ts +6 -0
  95. package/node_modules/@whatwg-node/node-fetch/typings/File.d.cts +7 -0
  96. package/node_modules/@whatwg-node/node-fetch/typings/File.d.ts +7 -0
  97. package/node_modules/@whatwg-node/node-fetch/typings/FormData.d.cts +22 -0
  98. package/node_modules/@whatwg-node/node-fetch/typings/FormData.d.ts +22 -0
  99. package/node_modules/@whatwg-node/node-fetch/typings/Headers.d.cts +26 -0
  100. package/node_modules/@whatwg-node/node-fetch/typings/Headers.d.ts +26 -0
  101. package/node_modules/@whatwg-node/node-fetch/typings/IteratorObject.d.cts +20 -0
  102. package/node_modules/@whatwg-node/node-fetch/typings/IteratorObject.d.ts +20 -0
  103. package/node_modules/@whatwg-node/node-fetch/typings/ReadableStream.d.cts +27 -0
  104. package/node_modules/@whatwg-node/node-fetch/typings/ReadableStream.d.ts +27 -0
  105. package/node_modules/@whatwg-node/node-fetch/typings/Request.d.cts +38 -0
  106. package/node_modules/@whatwg-node/node-fetch/typings/Request.d.ts +38 -0
  107. package/node_modules/@whatwg-node/node-fetch/typings/Response.d.cts +23 -0
  108. package/node_modules/@whatwg-node/node-fetch/typings/Response.d.ts +23 -0
  109. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoder.d.cts +15 -0
  110. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoder.d.ts +15 -0
  111. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoderStream.d.cts +14 -0
  112. package/node_modules/@whatwg-node/node-fetch/typings/TextEncoderDecoderStream.d.ts +14 -0
  113. package/node_modules/@whatwg-node/node-fetch/typings/TransformStream.d.cts +9 -0
  114. package/node_modules/@whatwg-node/node-fetch/typings/TransformStream.d.ts +9 -0
  115. package/node_modules/@whatwg-node/node-fetch/typings/URL.d.cts +16 -0
  116. package/node_modules/@whatwg-node/node-fetch/typings/URL.d.ts +16 -0
  117. package/node_modules/@whatwg-node/node-fetch/typings/URLSearchParams.d.cts +4 -0
  118. package/node_modules/@whatwg-node/node-fetch/typings/URLSearchParams.d.ts +4 -0
  119. package/node_modules/@whatwg-node/node-fetch/typings/WritableStream.d.cts +9 -0
  120. package/node_modules/@whatwg-node/node-fetch/typings/WritableStream.d.ts +9 -0
  121. package/node_modules/@whatwg-node/node-fetch/typings/fetch.d.cts +3 -0
  122. package/node_modules/@whatwg-node/node-fetch/typings/fetch.d.ts +3 -0
  123. package/node_modules/@whatwg-node/node-fetch/typings/fetchCurl.d.cts +3 -0
  124. package/node_modules/@whatwg-node/node-fetch/typings/fetchCurl.d.ts +3 -0
  125. package/node_modules/@whatwg-node/node-fetch/typings/fetchNodeHttp.d.cts +3 -0
  126. package/node_modules/@whatwg-node/node-fetch/typings/fetchNodeHttp.d.ts +3 -0
  127. package/node_modules/@whatwg-node/node-fetch/typings/index.d.cts +18 -0
  128. package/node_modules/@whatwg-node/node-fetch/typings/index.d.ts +18 -0
  129. package/node_modules/@whatwg-node/node-fetch/typings/utils.d.cts +21 -0
  130. package/node_modules/@whatwg-node/node-fetch/typings/utils.d.ts +21 -0
  131. package/node_modules/@whatwg-node/server/package.json +2 -1
  132. package/node_modules/urlpattern-polyfill/LICENSE +19 -0
  133. package/node_modules/urlpattern-polyfill/README.md +242 -0
  134. package/node_modules/urlpattern-polyfill/dist/index.d.ts +9 -0
  135. package/node_modules/urlpattern-polyfill/dist/types.d.ts +49 -0
  136. package/node_modules/urlpattern-polyfill/dist/urlpattern.cjs +1 -0
  137. package/node_modules/urlpattern-polyfill/dist/urlpattern.js +1 -0
  138. package/node_modules/urlpattern-polyfill/index.cjs +7 -0
  139. package/node_modules/urlpattern-polyfill/index.js +7 -0
  140. package/node_modules/urlpattern-polyfill/package.json +149 -0
  141. package/package.json +18 -8
  142. package/src/context.ts +1 -1
  143. package/src/index.ts +2 -0
  144. package/src/lib/map-share.ts +1 -1
  145. package/src/routes/maps.ts +1 -1
  146. package/src/types.ts +2 -2
@@ -0,0 +1,190 @@
1
+ 'use strict'
2
+
3
+ const Decoder = require('../utils/Decoder')
4
+ const decodeText = require('../utils/decodeText')
5
+ const getLimit = require('../utils/getLimit')
6
+
7
+ const RE_CHARSET = /^charset$/i
8
+
9
+ UrlEncoded.detect = /^application\/x-www-form-urlencoded/i
10
+ function UrlEncoded (boy, cfg) {
11
+ const limits = cfg.limits
12
+ const parsedConType = cfg.parsedConType
13
+ this.boy = boy
14
+
15
+ this.fieldSizeLimit = getLimit(limits, 'fieldSize', 1 * 1024 * 1024)
16
+ this.fieldNameSizeLimit = getLimit(limits, 'fieldNameSize', 100)
17
+ this.fieldsLimit = getLimit(limits, 'fields', Infinity)
18
+
19
+ let charset
20
+ for (var i = 0, len = parsedConType.length; i < len; ++i) { // eslint-disable-line no-var
21
+ if (Array.isArray(parsedConType[i]) &&
22
+ RE_CHARSET.test(parsedConType[i][0])) {
23
+ charset = parsedConType[i][1].toLowerCase()
24
+ break
25
+ }
26
+ }
27
+
28
+ if (charset === undefined) { charset = cfg.defCharset || 'utf8' }
29
+
30
+ this.decoder = new Decoder()
31
+ this.charset = charset
32
+ this._fields = 0
33
+ this._state = 'key'
34
+ this._checkingBytes = true
35
+ this._bytesKey = 0
36
+ this._bytesVal = 0
37
+ this._key = ''
38
+ this._val = ''
39
+ this._keyTrunc = false
40
+ this._valTrunc = false
41
+ this._hitLimit = false
42
+ }
43
+
44
+ UrlEncoded.prototype.write = function (data, cb) {
45
+ if (this._fields === this.fieldsLimit) {
46
+ if (!this.boy.hitFieldsLimit) {
47
+ this.boy.hitFieldsLimit = true
48
+ this.boy.emit('fieldsLimit')
49
+ }
50
+ return cb()
51
+ }
52
+
53
+ let idxeq; let idxamp; let i; let p = 0; const len = data.length
54
+
55
+ while (p < len) {
56
+ if (this._state === 'key') {
57
+ idxeq = idxamp = undefined
58
+ for (i = p; i < len; ++i) {
59
+ if (!this._checkingBytes) { ++p }
60
+ if (data[i] === 0x3D/* = */) {
61
+ idxeq = i
62
+ break
63
+ } else if (data[i] === 0x26/* & */) {
64
+ idxamp = i
65
+ break
66
+ }
67
+ if (this._checkingBytes && this._bytesKey === this.fieldNameSizeLimit) {
68
+ this._hitLimit = true
69
+ break
70
+ } else if (this._checkingBytes) { ++this._bytesKey }
71
+ }
72
+
73
+ if (idxeq !== undefined) {
74
+ // key with assignment
75
+ if (idxeq > p) { this._key += this.decoder.write(data.toString('binary', p, idxeq)) }
76
+ this._state = 'val'
77
+
78
+ this._hitLimit = false
79
+ this._checkingBytes = true
80
+ this._val = ''
81
+ this._bytesVal = 0
82
+ this._valTrunc = false
83
+ this.decoder.reset()
84
+
85
+ p = idxeq + 1
86
+ } else if (idxamp !== undefined) {
87
+ // key with no assignment
88
+ ++this._fields
89
+ let key; const keyTrunc = this._keyTrunc
90
+ if (idxamp > p) { key = (this._key += this.decoder.write(data.toString('binary', p, idxamp))) } else { key = this._key }
91
+
92
+ this._hitLimit = false
93
+ this._checkingBytes = true
94
+ this._key = ''
95
+ this._bytesKey = 0
96
+ this._keyTrunc = false
97
+ this.decoder.reset()
98
+
99
+ if (key.length) {
100
+ this.boy.emit('field', decodeText(key, 'binary', this.charset),
101
+ '',
102
+ keyTrunc,
103
+ false)
104
+ }
105
+
106
+ p = idxamp + 1
107
+ if (this._fields === this.fieldsLimit) { return cb() }
108
+ } else if (this._hitLimit) {
109
+ // we may not have hit the actual limit if there are encoded bytes...
110
+ if (i > p) { this._key += this.decoder.write(data.toString('binary', p, i)) }
111
+ p = i
112
+ if ((this._bytesKey = this._key.length) === this.fieldNameSizeLimit) {
113
+ // yep, we actually did hit the limit
114
+ this._checkingBytes = false
115
+ this._keyTrunc = true
116
+ }
117
+ } else {
118
+ if (p < len) { this._key += this.decoder.write(data.toString('binary', p)) }
119
+ p = len
120
+ }
121
+ } else {
122
+ idxamp = undefined
123
+ for (i = p; i < len; ++i) {
124
+ if (!this._checkingBytes) { ++p }
125
+ if (data[i] === 0x26/* & */) {
126
+ idxamp = i
127
+ break
128
+ }
129
+ if (this._checkingBytes && this._bytesVal === this.fieldSizeLimit) {
130
+ this._hitLimit = true
131
+ break
132
+ } else if (this._checkingBytes) { ++this._bytesVal }
133
+ }
134
+
135
+ if (idxamp !== undefined) {
136
+ ++this._fields
137
+ if (idxamp > p) { this._val += this.decoder.write(data.toString('binary', p, idxamp)) }
138
+ this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
139
+ decodeText(this._val, 'binary', this.charset),
140
+ this._keyTrunc,
141
+ this._valTrunc)
142
+ this._state = 'key'
143
+
144
+ this._hitLimit = false
145
+ this._checkingBytes = true
146
+ this._key = ''
147
+ this._bytesKey = 0
148
+ this._keyTrunc = false
149
+ this.decoder.reset()
150
+
151
+ p = idxamp + 1
152
+ if (this._fields === this.fieldsLimit) { return cb() }
153
+ } else if (this._hitLimit) {
154
+ // we may not have hit the actual limit if there are encoded bytes...
155
+ if (i > p) { this._val += this.decoder.write(data.toString('binary', p, i)) }
156
+ p = i
157
+ if ((this._val === '' && this.fieldSizeLimit === 0) ||
158
+ (this._bytesVal = this._val.length) === this.fieldSizeLimit) {
159
+ // yep, we actually did hit the limit
160
+ this._checkingBytes = false
161
+ this._valTrunc = true
162
+ }
163
+ } else {
164
+ if (p < len) { this._val += this.decoder.write(data.toString('binary', p)) }
165
+ p = len
166
+ }
167
+ }
168
+ }
169
+ cb()
170
+ }
171
+
172
+ UrlEncoded.prototype.end = function () {
173
+ if (this.boy._done) { return }
174
+
175
+ if (this._state === 'key' && this._key.length > 0) {
176
+ this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
177
+ '',
178
+ this._keyTrunc,
179
+ false)
180
+ } else if (this._state === 'val') {
181
+ this.boy.emit('field', decodeText(this._key, 'binary', this.charset),
182
+ decodeText(this._val, 'binary', this.charset),
183
+ this._keyTrunc,
184
+ this._valTrunc)
185
+ }
186
+ this.boy._done = true
187
+ this.boy.emit('finish')
188
+ }
189
+
190
+ module.exports = UrlEncoded
@@ -0,0 +1,54 @@
1
+ 'use strict'
2
+
3
+ const RE_PLUS = /\+/g
4
+
5
+ const HEX = [
6
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
7
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
8
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
10
+ 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
12
+ 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
13
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
14
+ ]
15
+
16
+ function Decoder () {
17
+ this.buffer = undefined
18
+ }
19
+ Decoder.prototype.write = function (str) {
20
+ // Replace '+' with ' ' before decoding
21
+ str = str.replace(RE_PLUS, ' ')
22
+ let res = ''
23
+ let i = 0; let p = 0; const len = str.length
24
+ for (; i < len; ++i) {
25
+ if (this.buffer !== undefined) {
26
+ if (!HEX[str.charCodeAt(i)]) {
27
+ res += '%' + this.buffer
28
+ this.buffer = undefined
29
+ --i // retry character
30
+ } else {
31
+ this.buffer += str[i]
32
+ ++p
33
+ if (this.buffer.length === 2) {
34
+ res += String.fromCharCode(parseInt(this.buffer, 16))
35
+ this.buffer = undefined
36
+ }
37
+ }
38
+ } else if (str[i] === '%') {
39
+ if (i > p) {
40
+ res += str.substring(p, i)
41
+ p = i
42
+ }
43
+ this.buffer = ''
44
+ ++p
45
+ }
46
+ }
47
+ if (p < len && this.buffer === undefined) { res += str.substring(p) }
48
+ return res
49
+ }
50
+ Decoder.prototype.reset = function () {
51
+ this.buffer = undefined
52
+ }
53
+
54
+ module.exports = Decoder
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+
3
+ module.exports = function basename (path) {
4
+ if (typeof path !== 'string') { return '' }
5
+ for (var i = path.length - 1; i >= 0; --i) { // eslint-disable-line no-var
6
+ switch (path.charCodeAt(i)) {
7
+ case 0x2F: // '/'
8
+ case 0x5C: // '\'
9
+ path = path.slice(i + 1)
10
+ return (path === '..' || path === '.' ? '' : path)
11
+ }
12
+ }
13
+ return (path === '..' || path === '.' ? '' : path)
14
+ }
@@ -0,0 +1,114 @@
1
+ 'use strict'
2
+
3
+ // Node has always utf-8
4
+ const utf8Decoder = new TextDecoder('utf-8')
5
+ const textDecoders = new Map([
6
+ ['utf-8', utf8Decoder],
7
+ ['utf8', utf8Decoder]
8
+ ])
9
+
10
+ function getDecoder (charset) {
11
+ let lc
12
+ while (true) {
13
+ switch (charset) {
14
+ case 'utf-8':
15
+ case 'utf8':
16
+ return decoders.utf8
17
+ case 'latin1':
18
+ case 'ascii': // TODO: Make these a separate, strict decoder?
19
+ case 'us-ascii':
20
+ case 'iso-8859-1':
21
+ case 'iso8859-1':
22
+ case 'iso88591':
23
+ case 'iso_8859-1':
24
+ case 'windows-1252':
25
+ case 'iso_8859-1:1987':
26
+ case 'cp1252':
27
+ case 'x-cp1252':
28
+ return decoders.latin1
29
+ case 'utf16le':
30
+ case 'utf-16le':
31
+ case 'ucs2':
32
+ case 'ucs-2':
33
+ return decoders.utf16le
34
+ case 'base64':
35
+ return decoders.base64
36
+ default:
37
+ if (lc === undefined) {
38
+ lc = true
39
+ charset = charset.toLowerCase()
40
+ continue
41
+ }
42
+ return decoders.other.bind(charset)
43
+ }
44
+ }
45
+ }
46
+
47
+ const decoders = {
48
+ utf8: (data, sourceEncoding) => {
49
+ if (data.length === 0) {
50
+ return ''
51
+ }
52
+ if (typeof data === 'string') {
53
+ data = Buffer.from(data, sourceEncoding)
54
+ }
55
+ return data.utf8Slice(0, data.length)
56
+ },
57
+
58
+ latin1: (data, sourceEncoding) => {
59
+ if (data.length === 0) {
60
+ return ''
61
+ }
62
+ if (typeof data === 'string') {
63
+ return data
64
+ }
65
+ return data.latin1Slice(0, data.length)
66
+ },
67
+
68
+ utf16le: (data, sourceEncoding) => {
69
+ if (data.length === 0) {
70
+ return ''
71
+ }
72
+ if (typeof data === 'string') {
73
+ data = Buffer.from(data, sourceEncoding)
74
+ }
75
+ return data.ucs2Slice(0, data.length)
76
+ },
77
+
78
+ base64: (data, sourceEncoding) => {
79
+ if (data.length === 0) {
80
+ return ''
81
+ }
82
+ if (typeof data === 'string') {
83
+ data = Buffer.from(data, sourceEncoding)
84
+ }
85
+ return data.base64Slice(0, data.length)
86
+ },
87
+
88
+ other: (data, sourceEncoding) => {
89
+ if (data.length === 0) {
90
+ return ''
91
+ }
92
+ if (typeof data === 'string') {
93
+ data = Buffer.from(data, sourceEncoding)
94
+ }
95
+
96
+ if (textDecoders.has(this.toString())) {
97
+ try {
98
+ return textDecoders.get(this).decode(data)
99
+ } catch {}
100
+ }
101
+ return typeof data === 'string'
102
+ ? data
103
+ : data.toString()
104
+ }
105
+ }
106
+
107
+ function decodeText (text, sourceEncoding, destEncoding) {
108
+ if (text) {
109
+ return getDecoder(destEncoding)(text, sourceEncoding)
110
+ }
111
+ return text
112
+ }
113
+
114
+ module.exports = decodeText
@@ -0,0 +1,16 @@
1
+ 'use strict'
2
+
3
+ module.exports = function getLimit (limits, name, defaultLimit) {
4
+ if (
5
+ !limits ||
6
+ limits[name] === undefined ||
7
+ limits[name] === null
8
+ ) { return defaultLimit }
9
+
10
+ if (
11
+ typeof limits[name] !== 'number' ||
12
+ isNaN(limits[name])
13
+ ) { throw new TypeError('Limit ' + name + ' is not a valid number') }
14
+
15
+ return limits[name]
16
+ }
@@ -0,0 +1,201 @@
1
+ /* eslint-disable object-property-newline */
2
+ 'use strict'
3
+
4
+ const decodeText = require('./decodeText')
5
+
6
+ const RE_ENCODED = /%[a-fA-F0-9][a-fA-F0-9]/g
7
+
8
+ const EncodedLookup = {
9
+ '%00': '\x00', '%01': '\x01', '%02': '\x02', '%03': '\x03', '%04': '\x04',
10
+ '%05': '\x05', '%06': '\x06', '%07': '\x07', '%08': '\x08', '%09': '\x09',
11
+ '%0a': '\x0a', '%0A': '\x0a', '%0b': '\x0b', '%0B': '\x0b', '%0c': '\x0c',
12
+ '%0C': '\x0c', '%0d': '\x0d', '%0D': '\x0d', '%0e': '\x0e', '%0E': '\x0e',
13
+ '%0f': '\x0f', '%0F': '\x0f', '%10': '\x10', '%11': '\x11', '%12': '\x12',
14
+ '%13': '\x13', '%14': '\x14', '%15': '\x15', '%16': '\x16', '%17': '\x17',
15
+ '%18': '\x18', '%19': '\x19', '%1a': '\x1a', '%1A': '\x1a', '%1b': '\x1b',
16
+ '%1B': '\x1b', '%1c': '\x1c', '%1C': '\x1c', '%1d': '\x1d', '%1D': '\x1d',
17
+ '%1e': '\x1e', '%1E': '\x1e', '%1f': '\x1f', '%1F': '\x1f', '%20': '\x20',
18
+ '%21': '\x21', '%22': '\x22', '%23': '\x23', '%24': '\x24', '%25': '\x25',
19
+ '%26': '\x26', '%27': '\x27', '%28': '\x28', '%29': '\x29', '%2a': '\x2a',
20
+ '%2A': '\x2a', '%2b': '\x2b', '%2B': '\x2b', '%2c': '\x2c', '%2C': '\x2c',
21
+ '%2d': '\x2d', '%2D': '\x2d', '%2e': '\x2e', '%2E': '\x2e', '%2f': '\x2f',
22
+ '%2F': '\x2f', '%30': '\x30', '%31': '\x31', '%32': '\x32', '%33': '\x33',
23
+ '%34': '\x34', '%35': '\x35', '%36': '\x36', '%37': '\x37', '%38': '\x38',
24
+ '%39': '\x39', '%3a': '\x3a', '%3A': '\x3a', '%3b': '\x3b', '%3B': '\x3b',
25
+ '%3c': '\x3c', '%3C': '\x3c', '%3d': '\x3d', '%3D': '\x3d', '%3e': '\x3e',
26
+ '%3E': '\x3e', '%3f': '\x3f', '%3F': '\x3f', '%40': '\x40', '%41': '\x41',
27
+ '%42': '\x42', '%43': '\x43', '%44': '\x44', '%45': '\x45', '%46': '\x46',
28
+ '%47': '\x47', '%48': '\x48', '%49': '\x49', '%4a': '\x4a', '%4A': '\x4a',
29
+ '%4b': '\x4b', '%4B': '\x4b', '%4c': '\x4c', '%4C': '\x4c', '%4d': '\x4d',
30
+ '%4D': '\x4d', '%4e': '\x4e', '%4E': '\x4e', '%4f': '\x4f', '%4F': '\x4f',
31
+ '%50': '\x50', '%51': '\x51', '%52': '\x52', '%53': '\x53', '%54': '\x54',
32
+ '%55': '\x55', '%56': '\x56', '%57': '\x57', '%58': '\x58', '%59': '\x59',
33
+ '%5a': '\x5a', '%5A': '\x5a', '%5b': '\x5b', '%5B': '\x5b', '%5c': '\x5c',
34
+ '%5C': '\x5c', '%5d': '\x5d', '%5D': '\x5d', '%5e': '\x5e', '%5E': '\x5e',
35
+ '%5f': '\x5f', '%5F': '\x5f', '%60': '\x60', '%61': '\x61', '%62': '\x62',
36
+ '%63': '\x63', '%64': '\x64', '%65': '\x65', '%66': '\x66', '%67': '\x67',
37
+ '%68': '\x68', '%69': '\x69', '%6a': '\x6a', '%6A': '\x6a', '%6b': '\x6b',
38
+ '%6B': '\x6b', '%6c': '\x6c', '%6C': '\x6c', '%6d': '\x6d', '%6D': '\x6d',
39
+ '%6e': '\x6e', '%6E': '\x6e', '%6f': '\x6f', '%6F': '\x6f', '%70': '\x70',
40
+ '%71': '\x71', '%72': '\x72', '%73': '\x73', '%74': '\x74', '%75': '\x75',
41
+ '%76': '\x76', '%77': '\x77', '%78': '\x78', '%79': '\x79', '%7a': '\x7a',
42
+ '%7A': '\x7a', '%7b': '\x7b', '%7B': '\x7b', '%7c': '\x7c', '%7C': '\x7c',
43
+ '%7d': '\x7d', '%7D': '\x7d', '%7e': '\x7e', '%7E': '\x7e', '%7f': '\x7f',
44
+ '%7F': '\x7f', '%80': '\x80', '%81': '\x81', '%82': '\x82', '%83': '\x83',
45
+ '%84': '\x84', '%85': '\x85', '%86': '\x86', '%87': '\x87', '%88': '\x88',
46
+ '%89': '\x89', '%8a': '\x8a', '%8A': '\x8a', '%8b': '\x8b', '%8B': '\x8b',
47
+ '%8c': '\x8c', '%8C': '\x8c', '%8d': '\x8d', '%8D': '\x8d', '%8e': '\x8e',
48
+ '%8E': '\x8e', '%8f': '\x8f', '%8F': '\x8f', '%90': '\x90', '%91': '\x91',
49
+ '%92': '\x92', '%93': '\x93', '%94': '\x94', '%95': '\x95', '%96': '\x96',
50
+ '%97': '\x97', '%98': '\x98', '%99': '\x99', '%9a': '\x9a', '%9A': '\x9a',
51
+ '%9b': '\x9b', '%9B': '\x9b', '%9c': '\x9c', '%9C': '\x9c', '%9d': '\x9d',
52
+ '%9D': '\x9d', '%9e': '\x9e', '%9E': '\x9e', '%9f': '\x9f', '%9F': '\x9f',
53
+ '%a0': '\xa0', '%A0': '\xa0', '%a1': '\xa1', '%A1': '\xa1', '%a2': '\xa2',
54
+ '%A2': '\xa2', '%a3': '\xa3', '%A3': '\xa3', '%a4': '\xa4', '%A4': '\xa4',
55
+ '%a5': '\xa5', '%A5': '\xa5', '%a6': '\xa6', '%A6': '\xa6', '%a7': '\xa7',
56
+ '%A7': '\xa7', '%a8': '\xa8', '%A8': '\xa8', '%a9': '\xa9', '%A9': '\xa9',
57
+ '%aa': '\xaa', '%Aa': '\xaa', '%aA': '\xaa', '%AA': '\xaa', '%ab': '\xab',
58
+ '%Ab': '\xab', '%aB': '\xab', '%AB': '\xab', '%ac': '\xac', '%Ac': '\xac',
59
+ '%aC': '\xac', '%AC': '\xac', '%ad': '\xad', '%Ad': '\xad', '%aD': '\xad',
60
+ '%AD': '\xad', '%ae': '\xae', '%Ae': '\xae', '%aE': '\xae', '%AE': '\xae',
61
+ '%af': '\xaf', '%Af': '\xaf', '%aF': '\xaf', '%AF': '\xaf', '%b0': '\xb0',
62
+ '%B0': '\xb0', '%b1': '\xb1', '%B1': '\xb1', '%b2': '\xb2', '%B2': '\xb2',
63
+ '%b3': '\xb3', '%B3': '\xb3', '%b4': '\xb4', '%B4': '\xb4', '%b5': '\xb5',
64
+ '%B5': '\xb5', '%b6': '\xb6', '%B6': '\xb6', '%b7': '\xb7', '%B7': '\xb7',
65
+ '%b8': '\xb8', '%B8': '\xb8', '%b9': '\xb9', '%B9': '\xb9', '%ba': '\xba',
66
+ '%Ba': '\xba', '%bA': '\xba', '%BA': '\xba', '%bb': '\xbb', '%Bb': '\xbb',
67
+ '%bB': '\xbb', '%BB': '\xbb', '%bc': '\xbc', '%Bc': '\xbc', '%bC': '\xbc',
68
+ '%BC': '\xbc', '%bd': '\xbd', '%Bd': '\xbd', '%bD': '\xbd', '%BD': '\xbd',
69
+ '%be': '\xbe', '%Be': '\xbe', '%bE': '\xbe', '%BE': '\xbe', '%bf': '\xbf',
70
+ '%Bf': '\xbf', '%bF': '\xbf', '%BF': '\xbf', '%c0': '\xc0', '%C0': '\xc0',
71
+ '%c1': '\xc1', '%C1': '\xc1', '%c2': '\xc2', '%C2': '\xc2', '%c3': '\xc3',
72
+ '%C3': '\xc3', '%c4': '\xc4', '%C4': '\xc4', '%c5': '\xc5', '%C5': '\xc5',
73
+ '%c6': '\xc6', '%C6': '\xc6', '%c7': '\xc7', '%C7': '\xc7', '%c8': '\xc8',
74
+ '%C8': '\xc8', '%c9': '\xc9', '%C9': '\xc9', '%ca': '\xca', '%Ca': '\xca',
75
+ '%cA': '\xca', '%CA': '\xca', '%cb': '\xcb', '%Cb': '\xcb', '%cB': '\xcb',
76
+ '%CB': '\xcb', '%cc': '\xcc', '%Cc': '\xcc', '%cC': '\xcc', '%CC': '\xcc',
77
+ '%cd': '\xcd', '%Cd': '\xcd', '%cD': '\xcd', '%CD': '\xcd', '%ce': '\xce',
78
+ '%Ce': '\xce', '%cE': '\xce', '%CE': '\xce', '%cf': '\xcf', '%Cf': '\xcf',
79
+ '%cF': '\xcf', '%CF': '\xcf', '%d0': '\xd0', '%D0': '\xd0', '%d1': '\xd1',
80
+ '%D1': '\xd1', '%d2': '\xd2', '%D2': '\xd2', '%d3': '\xd3', '%D3': '\xd3',
81
+ '%d4': '\xd4', '%D4': '\xd4', '%d5': '\xd5', '%D5': '\xd5', '%d6': '\xd6',
82
+ '%D6': '\xd6', '%d7': '\xd7', '%D7': '\xd7', '%d8': '\xd8', '%D8': '\xd8',
83
+ '%d9': '\xd9', '%D9': '\xd9', '%da': '\xda', '%Da': '\xda', '%dA': '\xda',
84
+ '%DA': '\xda', '%db': '\xdb', '%Db': '\xdb', '%dB': '\xdb', '%DB': '\xdb',
85
+ '%dc': '\xdc', '%Dc': '\xdc', '%dC': '\xdc', '%DC': '\xdc', '%dd': '\xdd',
86
+ '%Dd': '\xdd', '%dD': '\xdd', '%DD': '\xdd', '%de': '\xde', '%De': '\xde',
87
+ '%dE': '\xde', '%DE': '\xde', '%df': '\xdf', '%Df': '\xdf', '%dF': '\xdf',
88
+ '%DF': '\xdf', '%e0': '\xe0', '%E0': '\xe0', '%e1': '\xe1', '%E1': '\xe1',
89
+ '%e2': '\xe2', '%E2': '\xe2', '%e3': '\xe3', '%E3': '\xe3', '%e4': '\xe4',
90
+ '%E4': '\xe4', '%e5': '\xe5', '%E5': '\xe5', '%e6': '\xe6', '%E6': '\xe6',
91
+ '%e7': '\xe7', '%E7': '\xe7', '%e8': '\xe8', '%E8': '\xe8', '%e9': '\xe9',
92
+ '%E9': '\xe9', '%ea': '\xea', '%Ea': '\xea', '%eA': '\xea', '%EA': '\xea',
93
+ '%eb': '\xeb', '%Eb': '\xeb', '%eB': '\xeb', '%EB': '\xeb', '%ec': '\xec',
94
+ '%Ec': '\xec', '%eC': '\xec', '%EC': '\xec', '%ed': '\xed', '%Ed': '\xed',
95
+ '%eD': '\xed', '%ED': '\xed', '%ee': '\xee', '%Ee': '\xee', '%eE': '\xee',
96
+ '%EE': '\xee', '%ef': '\xef', '%Ef': '\xef', '%eF': '\xef', '%EF': '\xef',
97
+ '%f0': '\xf0', '%F0': '\xf0', '%f1': '\xf1', '%F1': '\xf1', '%f2': '\xf2',
98
+ '%F2': '\xf2', '%f3': '\xf3', '%F3': '\xf3', '%f4': '\xf4', '%F4': '\xf4',
99
+ '%f5': '\xf5', '%F5': '\xf5', '%f6': '\xf6', '%F6': '\xf6', '%f7': '\xf7',
100
+ '%F7': '\xf7', '%f8': '\xf8', '%F8': '\xf8', '%f9': '\xf9', '%F9': '\xf9',
101
+ '%fa': '\xfa', '%Fa': '\xfa', '%fA': '\xfa', '%FA': '\xfa', '%fb': '\xfb',
102
+ '%Fb': '\xfb', '%fB': '\xfb', '%FB': '\xfb', '%fc': '\xfc', '%Fc': '\xfc',
103
+ '%fC': '\xfc', '%FC': '\xfc', '%fd': '\xfd', '%Fd': '\xfd', '%fD': '\xfd',
104
+ '%FD': '\xfd', '%fe': '\xfe', '%Fe': '\xfe', '%fE': '\xfe', '%FE': '\xfe',
105
+ '%ff': '\xff', '%Ff': '\xff', '%fF': '\xff', '%FF': '\xff'
106
+ }
107
+
108
+ function encodedReplacer (match) {
109
+ return EncodedLookup[match]
110
+ }
111
+
112
+ const STATE_KEY = 0
113
+ const STATE_VALUE = 1
114
+ const STATE_CHARSET = 2
115
+ const STATE_LANG = 3
116
+
117
+ function parseParams (str) {
118
+ const res = []
119
+ let state = STATE_KEY
120
+ let charset = ''
121
+ let inquote = false
122
+ let escaping = false
123
+ let p = 0
124
+ let tmp = ''
125
+ const len = str.length
126
+
127
+ for (var i = 0; i < len; ++i) { // eslint-disable-line no-var
128
+ const char = str[i]
129
+ if (char === '\\' && inquote) {
130
+ if (escaping) { escaping = false } else {
131
+ escaping = true
132
+ continue
133
+ }
134
+ } else if (char === '"') {
135
+ if (!escaping) {
136
+ if (inquote) {
137
+ inquote = false
138
+ state = STATE_KEY
139
+ // Skip any remaining characters until we hit a semicolon or end of string
140
+ // This ensures we don't include characters after the closing quote
141
+ while (i + 1 < len && str[i + 1] !== ';') {
142
+ ++i
143
+ }
144
+ } else { inquote = true }
145
+ continue
146
+ } else { escaping = false }
147
+ } else {
148
+ if (escaping && inquote) { tmp += '\\' }
149
+ escaping = false
150
+ if ((state === STATE_CHARSET || state === STATE_LANG) && char === "'") {
151
+ if (state === STATE_CHARSET) {
152
+ state = STATE_LANG
153
+ charset = tmp.substring(1)
154
+ } else { state = STATE_VALUE }
155
+ tmp = ''
156
+ continue
157
+ } else if (state === STATE_KEY &&
158
+ (char === '*' || char === '=') &&
159
+ res.length) {
160
+ state = char === '*'
161
+ ? STATE_CHARSET
162
+ : STATE_VALUE
163
+ res[p] = [tmp, undefined]
164
+ tmp = ''
165
+ continue
166
+ } else if (!inquote && char === ';') {
167
+ state = STATE_KEY
168
+ if (charset) {
169
+ if (tmp.length) {
170
+ tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
171
+ 'binary',
172
+ charset)
173
+ }
174
+ charset = ''
175
+ } else if (tmp.length) {
176
+ tmp = decodeText(tmp, 'binary', 'utf8')
177
+ }
178
+ if (res[p] === undefined) { res[p] = tmp } else { res[p][1] = tmp }
179
+ tmp = ''
180
+ ++p
181
+ continue
182
+ } else if (!inquote && (char === ' ' || char === '\t')) { continue }
183
+ }
184
+ tmp += char
185
+ }
186
+ if (charset && tmp.length) {
187
+ tmp = decodeText(tmp.replace(RE_ENCODED, encodedReplacer),
188
+ 'binary',
189
+ charset)
190
+ } else if (tmp) {
191
+ tmp = decodeText(tmp, 'binary', 'utf8')
192
+ }
193
+
194
+ if (res[p] === undefined) {
195
+ if (tmp) { res[p] = tmp }
196
+ } else { res[p][1] = tmp }
197
+
198
+ return res
199
+ }
200
+
201
+ module.exports = parseParams