Merge branch '888-fix-utf8-base64-decoding' into 'develop'
After Store: Correctly decode UTF-8 encoded base64 strings. Closes #888 See merge request pleroma/pleroma-fe!1176
This commit is contained in:
commit
d2f0e4e7d5
|
@ -20,12 +20,20 @@ const parsedInitialResults = () => {
|
||||||
return staticInitialResults
|
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 preloadFetch = async (request) => {
|
||||||
const data = parsedInitialResults()
|
const data = parsedInitialResults()
|
||||||
if (!data || !data[request]) {
|
if (!data || !data[request]) {
|
||||||
return window.fetch(request)
|
return window.fetch(request)
|
||||||
}
|
}
|
||||||
const requestData = JSON.parse(atob(data[request]))
|
const decoded = decodeUTF8Base64(data[request])
|
||||||
|
const requestData = JSON.parse(decoded)
|
||||||
return {
|
return {
|
||||||
ok: true,
|
ok: true,
|
||||||
json: () => requestData,
|
json: () => requestData,
|
||||||
|
|
Loading…
Reference in New Issue