replace . base64 character with ~ because discord things a . in the end is not part of the url

[deploy]
This commit is contained in:
2023-07-09 01:47:16 +02:00
parent c4fee59446
commit 7fdf1cd3b4

View File

@@ -11,7 +11,7 @@ export async function toBase64(blob: Blob): Promise<string> {
resolve(
(reader.result as string)
.replace(/^data:application\/octet-stream;base64,/, "")
.replaceAll("+", ".")
.replaceAll("+", "~")
.replaceAll("/", "_")
.replaceAll("=", "-"),
)
@@ -23,7 +23,7 @@ export async function toBase64(blob: Blob): Promise<string> {
export async function fromBase64(base64: string): Promise<Blob> {
return fetch(
`data:application/octet-stream;base64,${base64
.replaceAll(".", "+")
.replaceAll("~", "+")
.replaceAll("_", "/")
.replaceAll("-", "=")}`,
).then(it => it.blob())