dat-encoding
Advanced tools
Comparing version 4.0.1 to 4.0.2
@@ -7,4 +7,5 @@ 'use strict' | ||
if (typeof buf === 'string') return encode(decode(buf)) | ||
if (!Buffer.isBuffer(buf)) throw new Error('Not a buffer') | ||
if (buf.length !== 32) throw new Error('Invalid buffer') | ||
return Buffer.from(buf).toString('hex') | ||
return buf.toString('hex') | ||
} | ||
@@ -14,3 +15,4 @@ | ||
if (Buffer.isBuffer(str)) return decode(encode(str)) | ||
var match = /(?:[a-z]+:\/\/(?:dat\.land\/)?)?([^/]{64})/.exec(str) | ||
if (typeof str !== 'string') throw new Error('Not a string') | ||
var match = /\/?([^/]{64})/.exec(str) | ||
if (!match) throw new Error('Invalid key') | ||
@@ -17,0 +19,0 @@ return Buffer.from(match[1], 'hex') |
{ | ||
"name": "dat-encoding", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "repository": "juliangruber/dat-encoding", |
@@ -11,2 +11,3 @@ var test = require('tape') | ||
{type: 'valid', key: 'dat.land/6161616161616161616161616161616161616161616161616161616161616161/'}, | ||
{type: 'valid', key: 'host.com/whatever/6161616161616161616161616161616161616161616161616161616161616161'}, | ||
{type: 'invalid', key: new Buffer('key-me-maybe', 'hex')}, | ||
@@ -13,0 +14,0 @@ {type: 'invalid', key: 'key-me-maybe'}, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5369
105