Skip to content
Snippets Groups Projects
Commit 1e40b5ec authored by Dan Notestein's avatar Dan Notestein
Browse files

Merge branch 'utf' into 'master'

Encoding improvement

See merge request !1
parents 80ee90c3 86aea173
Branches master
No related tags found
1 merge request!1Encoding improvement
{
"name": "hive-uri",
"version": "0.2.4",
"version": "0.2.5",
"description": "Hive URI parser and encoder",
"license": "MIT",
"main": "./lib/index",
......
......@@ -9,16 +9,16 @@ if (typeof URLSearchParams === 'undefined') {
global['URLSearchParams'] = require('url').URLSearchParams
}
if (typeof btoa === 'undefined') {
global['btoa'] = (str) => new Buffer(str, 'binary').toString('base64')
global['btoa'] = (str) => Buffer.from(str, 'binary').toString('base64')
}
if (typeof atob === 'undefined') {
global['atob'] = (str) => new Buffer(str, 'base64').toString('binary')
global['atob'] = (str) => Buffer.from(str, 'base64').toString('binary')
}
/// URL-safe Base64 encoding and decoding.
const B64U_LOOKUP = {'/': '_', '_': '/', '+': '-', '-': '+', '=': '.', '.': '='}
const b64uEnc = (str) => btoa(str).replace(/(\+|\/|=)/g, (m) => B64U_LOOKUP[m])
const b64uDec = (str) => atob(str.replace(/(-|_|\.)/g, (m) => B64U_LOOKUP[m]))
const b64uEnc = (str) => btoa(unescape(encodeURIComponent(str))).replace(/(\+|\/|=)/g, (m) => B64U_LOOKUP[m])
const b64uDec = (str) => decodeURIComponent(escape(atob(str.replace(/(-|_|\.)/g, (m) => B64U_LOOKUP[m]))))
/**
* Protocol parameters.
......@@ -202,7 +202,7 @@ export interface TransactionConfirmation {
txn?: number
}
const CALLBACK_RESOLVE_PATTERN = /({{(sig|id|block|txn)}})/g
const CALLBACK_RESOLVE_PATTERN = /({{(sig|id|block|txn|data)}})/g
/**
* Resolves template vars in a callback url.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment