src/xoauth2.js
function toBase64URL(data) {
    if (typeof data === 'string') {
        data = new Buffer(data);
    }

    return data.toString('base64')
        .replace(/=+/g, '')     // remove '='s
        .replace(/\+/g, '-')    // '+' → '-'
        .replace(/\//g, '_');   // '/' → '_'
}
function toBase64URL(data) {
    if (typeof data === 'string') {
        data = new Buffer(data);
    }

    return data.toString('base64')
        .replace(/=+/g, '')     // remove '='s
        .replace(/\+/g, '-')    // '+' → '-'
        .replace(/\//g, '_');   // '/' → '_'
}
function toBase64URL ( data ) { if ( typeof data === 'string' ) { data = new Buffer ( data ) ; } return data . toString ( 'base64' ) . replace ( / =+ / g , '' ) // remove '='s . replace ( / \+ / g , '-' ) // '+' → '-' . replace ( / \/ / g , '_' ) ; // '/' → '_' }
Encodes a buffer or a string into Base64url format

@param {Buffer|String} data The data to convert
@return {String} The encoded string
Encodes a buffer or a string into Base64url format