diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-09-20 07:50:23 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-09-20 09:35:33 -1000 |
commit | a9feab3b1f5335b14fc0feba4da2b9fe40aa1224 (patch) | |
tree | bf6f10ae9a721c1f531b18b6aec9d84463485151 /lib/util.js | |
parent | 73022a68b920123bf3c150dbce5d5872f6f00669 (diff) | |
download | patchfoo-a9feab3b1f5335b14fc0feba4da2b9fe40aa1224.tar.gz patchfoo-a9feab3b1f5335b14fc0feba4da2b9fe40aa1224.zip |
Render npm package publishers
Diffstat (limited to 'lib/util.js')
-rw-r--r-- | lib/util.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js index c6a4aa2..fb0b13f 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,6 +1,7 @@ var pull = require('pull-stream') var cat = require('pull-cat') var h = require('hyperscript') +var b64url = require('base64-url') var u = exports u.ssbRefRegex = /((?:@|%|&|ssb:\/\/%)[A-Za-z0-9\/+]{43}=\.[\w\d]+)/g @@ -206,3 +207,13 @@ u.mergeOpts = function (a, b) { } return obj } + +u.escapeId = function (id) { + return b64url.escape(id) +} + +u.unescapeId = function (str) { + var m = /^(.)(.*)(\..*)$/.exec(str) + if (!m) return b64url.unescape(str) + return m[1] + b64url.unescape(m[2]) + m[3] +} |