mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
fix(desktop): non-latin file paths failed
This commit is contained in:
parent
1bce898ca7
commit
184643f0db
1 changed files with 6 additions and 2 deletions
|
|
@ -1,9 +1,13 @@
|
|||
export function base64Encode(value: string) {
|
||||
return btoa(value).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")
|
||||
const bytes = new TextEncoder().encode(value)
|
||||
const binary = Array.from(bytes, (b) => String.fromCharCode(b)).join("")
|
||||
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "")
|
||||
}
|
||||
|
||||
export function base64Decode(value: string) {
|
||||
return atob(value.replace(/-/g, "+").replace(/_/g, "/"))
|
||||
const binary = atob(value.replace(/-/g, "+").replace(/_/g, "/"))
|
||||
const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0))
|
||||
return new TextDecoder().decode(bytes)
|
||||
}
|
||||
|
||||
export async function hash(content: string, algorithm = "SHA-256"): Promise<string> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue