forked from AkkomaGang/akkoma-fe
Fix basicauth base64 encoding for unicode passwords.
This commit is contained in:
parent
f72d6ec83e
commit
f4f63d32e2
1 changed files with 11 additions and 1 deletions
|
@ -43,6 +43,16 @@ let fetch = (url, options) => {
|
|||
return oldfetch(fullUrl, options)
|
||||
}
|
||||
|
||||
// from https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
|
||||
let utoa = (str) => {
|
||||
// first we use encodeURIComponent to get percent-encoded UTF-8,
|
||||
// then we convert the percent encodings into raw bytes which
|
||||
// can be fed into btoa.
|
||||
return btoa(encodeURIComponent(str)
|
||||
.replace(/%([0-9A-F]{2})/g,
|
||||
(match, p1) => { return String.fromCharCode('0x' + p1) }))
|
||||
}
|
||||
|
||||
// Params
|
||||
// cropH
|
||||
// cropW
|
||||
|
@ -156,7 +166,7 @@ const register = (params) => {
|
|||
|
||||
const authHeaders = (user) => {
|
||||
if (user && user.username && user.password) {
|
||||
return { 'Authorization': `Basic ${btoa(`${user.username}:${user.password}`)}` }
|
||||
return { 'Authorization': `Basic ${utoa(`${user.username}:${user.password}`)}` }
|
||||
} else {
|
||||
return { }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue