Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/websocket/01_websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
if (this.binaryType === "blob") {
data = new Blob([value]);
} else {
data = value.buffer;
data = value;
}

const event = new MessageEvent("message", {
Expand Down
19 changes: 18 additions & 1 deletion serde_v8/magic/string_or_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,24 @@ impl ToV8 for StringOrBuffer {
scope: &mut v8::HandleScope<'a>,
) -> Result<v8::Local<'a, v8::Value>, crate::Error> {
match self {
Self::Buffer(buf) => crate::to_v8(scope, buf),
Self::Buffer(buf) => {
let buf: Box<[u8]> = match buf {
ZeroCopyBuf::FromV8(buf) => {
let value: &[u8] = buf;
value.into()
}
ZeroCopyBuf::Temp(_) => unreachable!(),
ZeroCopyBuf::ToV8(ref mut x) => {
x.take().expect("ZeroCopyBuf was empty")
}
};
let backing_store =
v8::ArrayBuffer::new_backing_store_from_boxed_slice(buf);
Ok(
v8::ArrayBuffer::with_backing_store(scope, &backing_store.into())
.into(),
)
}
Self::String(s) => crate::to_v8(scope, s),
}
}
Expand Down