(data)
| 15675 | return output; |
| 15676 | } |
| 15677 | parseCloseBody(data) { |
| 15678 | assert(data.length !== 1); |
| 15679 | let code; |
| 15680 | if (data.length >= 2) { |
| 15681 | code = data.readUInt16BE(0); |
| 15682 | } |
| 15683 | if (code !== void 0 && !isValidStatusCode(code)) { |
| 15684 | return { code: 1002, reason: "Invalid status code", error: true }; |
| 15685 | } |
| 15686 | let reason = data.subarray(2); |
| 15687 | if (reason[0] === 239 && reason[1] === 187 && reason[2] === 191) { |
| 15688 | reason = reason.subarray(3); |
| 15689 | } |
| 15690 | try { |
| 15691 | reason = utf8Decode(reason); |
| 15692 | } catch { |
| 15693 | return { code: 1007, reason: "Invalid UTF-8", error: true }; |
| 15694 | } |
| 15695 | return { code, reason, error: false }; |
| 15696 | } |
| 15697 | /** |
| 15698 | * Parses control frames. |
| 15699 | * @param {Buffer} body |
no test coverage detected