diff --git a/platform/src/FileHandler.js b/platform/src/FileHandler.js index 84dc0d7..56ed811 100644 --- a/platform/src/FileHandler.js +++ b/platform/src/FileHandler.js @@ -10,6 +10,11 @@ class FileHandler { } + base64ToBytes(base64) { + const binString = window.atob(base64); + return Uint8Array.from(binString, (m) => m.codePointAt(0)); + } + fetchFile(url, isPrivate){ if (isPrivate){ @@ -19,14 +24,17 @@ class FileHandler { if (requestUrl != null) { var xhr = new XMLHttpRequest(); xhr.open("GET", requestUrl, false); + xhr.setRequestHeader("Accept", "application/json; charset=UTF-8"); xhr.withCredentials = true; xhr.send(); if (xhr.status === 200) { let response = JSON.parse(xhr.responseText); - - return { content: window.atob(response.data.content), sha: response.data.sha }; + + let contents = new TextDecoder().decode(this.base64ToBytes(response.data.content)); + + return { content: contents, sha: response.data.sha }; } else { return null; diff --git a/platform/src/Utility.js b/platform/src/Utility.js index 21df2a8..f0f0322 100644 --- a/platform/src/Utility.js +++ b/platform/src/Utility.js @@ -45,7 +45,7 @@ export function jsonRequest(url, json, useCredentials=false){ var xhr = new XMLHttpRequest(); xhr.open("POST", url); - xhr.setRequestHeader("Content-Type", "application/json"); + xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8"); xhr.withCredentials = useCredentials; xhr.onload = function () {