mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
fix: correct clipboard image encoding and binary handling (#3817)
This commit is contained in:
parent
47b2fb79dc
commit
2c3aa330b9
1 changed files with 7 additions and 7 deletions
|
|
@ -30,13 +30,13 @@ export namespace Clipboard {
|
|||
}
|
||||
|
||||
if (os === "linux") {
|
||||
const wayland = await $`wl-paste -t image/png`.nothrow().text()
|
||||
if (wayland) {
|
||||
return { data: Buffer.from(wayland).toString("base64url"), mime: "image/png" }
|
||||
const wayland = await $`wl-paste -t image/png`.nothrow().arrayBuffer()
|
||||
if (wayland && wayland.byteLength > 0) {
|
||||
return { data: Buffer.from(wayland).toString("base64"), mime: "image/png" }
|
||||
}
|
||||
const x11 = await $`xclip -selection clipboard -t image/png -o`.nothrow().text()
|
||||
if (x11) {
|
||||
return { data: Buffer.from(x11).toString("base64url"), mime: "image/png" }
|
||||
const x11 = await $`xclip -selection clipboard -t image/png -o`.nothrow().arrayBuffer()
|
||||
if (x11 && x11.byteLength > 0) {
|
||||
return { data: Buffer.from(x11).toString("base64"), mime: "image/png" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ export namespace Clipboard {
|
|||
if (base64) {
|
||||
const imageBuffer = Buffer.from(base64.trim(), "base64")
|
||||
if (imageBuffer.length > 0) {
|
||||
return { data: imageBuffer.toString("base64url"), mime: "image/png" }
|
||||
return { data: imageBuffer.toString("base64"), mime: "image/png" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue