mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 04:43:12 +03:00
411ce69006
refs #9178 - we could now also move any crypto usages to lib/security, but no priority - the main goal is to tidy up our utils folder
15 lines
604 B
JavaScript
15 lines
604 B
JavaScript
// The token is encoded URL safe by replacing '+' with '-', '\' with '_' and removing '='
|
|
// NOTE: the token is not encoded using valid base64 anymore
|
|
module.exports.encodeBase64 = function encodeBase64(base64String) {
|
|
return base64String.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
};
|
|
|
|
// Decode url safe base64 encoding and add padding ('=')
|
|
module.exports.decodeBase64 = function decodeBase64(base64String) {
|
|
base64String = base64String.replace(/-/g, '+').replace(/_/g, '/');
|
|
while (base64String.length % 4) {
|
|
base64String += '=';
|
|
}
|
|
return base64String;
|
|
};
|