mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-11-11 00:41:45 +08:00
fix(onboarding): properly base64 encode string
This commit is contained in:
parent
81c8cd6a8b
commit
e5ca74684d
1 changed files with 10 additions and 2 deletions
|
|
@ -4,8 +4,16 @@ import crypto from 'crypto';
|
||||||
import {EdgehillAPI, NylasAPI, AccountStore, RegExpUtils, IdentityStore} from 'nylas-exports';
|
import {EdgehillAPI, NylasAPI, AccountStore, RegExpUtils, IdentityStore} from 'nylas-exports';
|
||||||
import url from 'url';
|
import url from 'url';
|
||||||
|
|
||||||
function base64url(buf) {
|
function base64url(inBuffer) {
|
||||||
return buf.toString('base64')
|
let buffer;
|
||||||
|
if (typeof inBuffer === "string") {
|
||||||
|
buffer = new Buffer(inBuffer);
|
||||||
|
} else if (inBuffer instanceof Buffer) {
|
||||||
|
buffer = inBuffer;
|
||||||
|
} else {
|
||||||
|
throw new Error(`${inBuffer} must be a string or Buffer`)
|
||||||
|
}
|
||||||
|
return buffer.toString('base64')
|
||||||
.replace(/\+/g, '-') // Convert '+' to '-'
|
.replace(/\+/g, '-') // Convert '+' to '-'
|
||||||
.replace(/\//g, '_'); // Convert '/' to '_'
|
.replace(/\//g, '_'); // Convert '/' to '_'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue