mirror of
https://git.youjo.love/youjo/youjo-fe.git
synced 2024-11-20 13:59:55 +01:00
After Store: Correctly decode UTF-8 encoded base64 strings.
This commit is contained in:
parent
2b3c4ccfae
commit
905de12980
1 changed files with 9 additions and 1 deletions
|
@ -20,12 +20,20 @@ const parsedInitialResults = () => {
|
|||
return staticInitialResults
|
||||
}
|
||||
|
||||
const decodeUTF8Base64 = (data) => {
|
||||
const rawData = atob(data)
|
||||
const array = Uint8Array.from([...rawData].map((char) => char.charCodeAt(0)))
|
||||
const text = new TextDecoder().decode(array)
|
||||
return text
|
||||
}
|
||||
|
||||
const preloadFetch = async (request) => {
|
||||
const data = parsedInitialResults()
|
||||
if (!data || !data[request]) {
|
||||
return window.fetch(request)
|
||||
}
|
||||
const requestData = JSON.parse(atob(data[request]))
|
||||
const decoded = decodeUTF8Base64(data[request])
|
||||
const requestData = JSON.parse(decoded)
|
||||
return {
|
||||
ok: true,
|
||||
json: () => requestData,
|
||||
|
|
Loading…
Reference in a new issue