Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dat-encoding

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dat-encoding - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

4

index.js

@@ -15,3 +15,5 @@ 'use strict'

if (typeof str !== 'string') throw new Error('Not a string')
var match = /\/?([^/]{64,65})/.exec(str)
// looking for an hexa string of 64 or 65 consecutive chars
var match = /([a-f0-9]{64,65})/i.exec(str)
// we need exactly 64, so an hexa string with 65 chars (or more) is not allowed
if (!match || match[1].length !== 64) throw new Error('Invalid key')

@@ -18,0 +20,0 @@ return Buffer.from(match[1], 'hex')

{
"name": "dat-encoding",
"version": "5.0.0",
"version": "5.0.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "repository": "juliangruber/dat-encoding",

@@ -12,5 +12,5 @@ var test = require('tape')

{type: 'valid', key: 'host.com/whatever/6161616161616161616161616161616161616161616161616161616161616161'},
{type: 'invalid', key: 'z6161616161616161616161616161616161616161616161616161616161616161'},
{type: 'valid', key: 'z6161616161616161616161616161616161616161616161616161616161616161'},
{type: 'valid', key: '6161616161616161616161616161616161616161616161616161616161616161z'},
{type: 'invalid', key: '6161616161616161616161616161z616161616161616161616161616161616161'},
{type: 'invalid', key: '6161616161616161616161616161616161616161616161616161616161616161z'},
{type: 'invalid', key: '616161616161616161616161616161616161616161616161616161616161616'},

@@ -85,3 +85,3 @@ {type: 'invalid', key: '61616161616161616161616161616161616161616161616161616161616161601'},

t.equal(typeof newKey, 'string')
t.ok(enc.decode(newKey), 'valid key is now valid buf')
t.ok(enc.decode(newKey), 'valid key is now valid buffer')
}

@@ -108,1 +108,15 @@ })

})
test('toStr with path', function (t) {
t.plan(2)
var newKey = enc.toStr('3161616161616161616161616161616161616161616161616161616161616161/path')
t.equal(newKey, '3161616161616161616161616161616161616161616161616161616161616161')
t.ok(enc.decode(newKey), 'valid key is now valid buffer')
})
test('toStr with version', function (t) {
t.plan(2)
var newKey = enc.toStr('4161616161616161616161616161616161616161616161616161616161616161+5')
t.equal(newKey, '4161616161616161616161616161616161616161616161616161616161616161')
t.ok(enc.decode(newKey), 'valid key is now valid buffer')
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc