Spaces:
Paused
Paused
Download node_modules/@fastify/busboy/lib/utils/Decoder.js from Huzaifa1313/Prof_app: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/spaces/Huzaifa1313/Prof_app/resolve/main/node_modules/%40fastify/busboy/lib/utils/Decoder.js
- Command line
-
hf download hf://spaces/Huzaifa1313/Prof_app/node_modules/@fastify/busboy/lib/utils/Decoder.js
-
curl -L -o Decoder.js https://huggingface.co/spaces/Huzaifa1313/Prof_app/resolve/main/node_modules/%40fastify/busboy/lib/utils/Decoder.js
1.43 kB
| const RE_PLUS = /\+/g | |
| const HEX = [ | |
| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, | |
| 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | |
| ] | |
| function Decoder () { | |
| this.buffer = undefined | |
| } | |
| Decoder.prototype.write = function (str) { | |
| // Replace '+' with ' ' before decoding | |
| str = str.replace(RE_PLUS, ' ') | |
| let res = '' | |
| let i = 0; let p = 0; const len = str.length | |
| for (; i < len; ++i) { | |
| if (this.buffer !== undefined) { | |
| if (!HEX[str.charCodeAt(i)]) { | |
| res += '%' + this.buffer | |
| this.buffer = undefined | |
| --i // retry character | |
| } else { | |
| this.buffer += str[i] | |
| ++p | |
| if (this.buffer.length === 2) { | |
| res += String.fromCharCode(parseInt(this.buffer, 16)) | |
| this.buffer = undefined | |
| } | |
| } | |
| } else if (str[i] === '%') { | |
| if (i > p) { | |
| res += str.substring(p, i) | |
| p = i | |
| } | |
| this.buffer = '' | |
| ++p | |
| } | |
| } | |
| if (p < len && this.buffer === undefined) { res += str.substring(p) } | |
| return res | |
| } | |
| Decoder.prototype.reset = function () { | |
| this.buffer = undefined | |
| } | |
| module.exports = Decoder | |