feat: support WKWebview custom protocol (#1113)

pull/1127/head
Aiden McClelland 2020-10-21 08:41:09 -06:00 committed by GitHub
parent 0dca0b92d1
commit 0ac80e8387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -85,6 +85,11 @@ export function download (format, ...files) {
export async function post (url, content = '', overwrite = false, onupload) {
url = removePrefix(url)
let bufferContent
if (content instanceof Blob && !['http:', 'https:'].includes(window.location.protocol)) {
bufferContent = await new Response(content).arrayBuffer()
}
return new Promise((resolve, reject) => {
let request = new XMLHttpRequest()
request.open('POST', `${baseURL}/api/resources${url}?override=${overwrite}`, true)
@ -108,7 +113,7 @@ export async function post (url, content = '', overwrite = false, onupload) {
reject(error)
}
request.send(content)
request.send(bufferContent || content)
})
}