diff --git a/index.d.ts b/index.d.ts index 45ad4374..909382cf 100644 --- a/index.d.ts +++ b/index.d.ts @@ -61,6 +61,7 @@ declare module 'mock-socket' { class Server extends EventTarget { constructor(url: string, options?: ServerOptions); + readonly url: string; readonly options?: ServerOptions; stop(callback?: () => void): void; diff --git a/src/helpers/normalize-send.js b/src/helpers/normalize-send.js index ebb209bb..4fa6f25b 100644 --- a/src/helpers/normalize-send.js +++ b/src/helpers/normalize-send.js @@ -1,5 +1,7 @@ export default function normalizeSendData(data) { - if (Object.prototype.toString.call(data) !== '[object Blob]' && !(data instanceof ArrayBuffer)) { + if (data instanceof Buffer) { + data = data.buffer; + } else if (Object.prototype.toString.call(data) !== '[object Blob]' && !(data instanceof ArrayBuffer)) { data = String(data); }