SAP-BTP-Spielwiese/app1/node_modules/base64-url/index.js
Markus Rettig 775ac7b58c completed step 3 from the tutorial
you must login with an BTP account in order to see the app
2024-02-08 16:13:36 +01:00

28 lines
568 B
JavaScript

'use strict'
module.exports = {
unescape: unescape,
escape: escape,
encode: encode,
decode: decode
}
function unescape (str) {
return (str + '==='.slice((str.length + 3) % 4))
.replace(/-/g, '+')
.replace(/_/g, '/')
}
function escape (str) {
return str.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '')
}
function encode (str, encoding) {
return escape(Buffer.from(str, encoding || 'utf8').toString('base64'))
}
function decode (str, encoding) {
return Buffer.from(unescape(str), 'base64').toString(encoding || 'utf8')
}