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

short-uuid

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

short-uuid - npm Package Compare versions

Comparing version 2.3.3 to 2.3.4

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Change Log

## [2.3.4] - 2017-08-08
### Changed
- Corrected shortenUUID function in [index.js]
- Added test cases for uppercase in [test/index.js]
- Added 2.3.4 fix notes in [README.md]
- Refactored "random" test cases so only the assertions loop in [test/index.js]
- Updated devDependencies for codeclimate-test-reporter in [package.json]
- Included Node 8.x support in [.travis.yml]
## [2.3.3] - 2017-05-22

@@ -7,0 +16,0 @@ ### Changed

2

dist/short-uuid.js

@@ -21,3 +21,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ShortUUID = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

function shortenUUID (longId, translator) {
return translator(longId.replace(/-/g,''));
return translator(longId.toLowerCase().replace(/-/g,''));
}

@@ -24,0 +24,0 @@

@@ -1,3 +0,3 @@

/*! short-uuid v2.3.3 - 2017-05-22 */
/*! short-uuid v2.3.4 - 2017-08-08 */
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ShortUUID=r()}}(function(){return function r(n,t,e){function o(u,f){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var c=t[u]={exports:{}};n[u][0].call(c.exports,function(r){var t=n[u][1][r];return o(t||r)},c,c.exports,r,n,t,e)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<e.length;u++)o(e[u]);return o}({1:[function(r,n,t){n.exports=function(){function n(r,n){return n(r.replace(/-/g,""))}function t(r,n){for(var t,e=n(r),o="",i=0,u=32-e.length;i<u;++i)o+="0";return t=(o+e).match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/),[t[1],t[2],t[3],t[4],t[5]].join("-")}function e(r){var e=r||u,f=o(o.HEX,e),a=o(e,o.HEX);return{new:function(){return n(i(),f)},uuid:i,fromUUID:function(r){return n(r,f)},toUUID:function(r){return t(r,a)},alphabet:e}}var o=r("any-base"),i=r("uuid/v4"),u="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";return e.constants={flickrBase58:u,cookieBase90:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~"},e.uuid=i,e}()},{"any-base":2,"uuid/v4":6}],2:[function(r,n,t){function e(r,n){var t=new o(r,n);return function(r){return t.convert(r)}}var o=r("./src/converter");e.BIN="01",e.OCT="01234567",e.DEC="0123456789",e.HEX="0123456789abcdef",n.exports=e},{"./src/converter":3}],3:[function(r,n,t){"use strict";function e(r,n){if(!(r&&n&&r.length&&n.length))throw new Error("Bad alphabet");this.srcAlphabet=r,this.dstAlphabet=n}e.prototype.convert=function(r){var n,t,e,o={},i=this.srcAlphabet.length,u=this.dstAlphabet.length,f=r.length,a="";if(this.srcAlphabet===this.dstAlphabet)return r;for(n=0;n<f;n++)o[n]=this.srcAlphabet.indexOf(r[n]);do{for(t=0,e=0,n=0;n<f;n++)(t=t*i+o[n])>=u?(o[e++]=parseInt(t/u,10),t%=u):e>0&&(o[e++]=0);f=e,a=this.dstAlphabet[t]+a}while(0!=e);return a},n.exports=e},{}],4:[function(r,n,t){function e(r,n){var t=n||0,e=o;return e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]}for(var o=[],i=0;i<256;++i)o[i]=(i+256).toString(16).substr(1);n.exports=e},{}],5:[function(r,n,t){var e,o=global.crypto||global.msCrypto;if(o&&o.getRandomValues){var i=new Uint8Array(16);e=function(){return o.getRandomValues(i),i}}if(!e){var u=new Array(16);e=function(){for(var r,n=0;n<16;n++)0==(3&n)&&(r=4294967296*Math.random()),u[n]=r>>>((3&n)<<3)&255;return u}}n.exports=e},{}],6:[function(r,n,t){function e(r,n,t){var e=n&&t||0;"string"==typeof r&&(n="binary"==r?new Array(16):null,r=null);var u=(r=r||{}).random||(r.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,n)for(var f=0;f<16;++f)n[e+f]=u[f];return n||i(u)}var o=r("./lib/rng"),i=r("./lib/bytesToUuid");n.exports=e},{"./lib/bytesToUuid":4,"./lib/rng":5}]},{},[1])(1)});
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ShortUUID=r()}}(function(){return function r(n,t,e){function o(u,f){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var c=t[u]={exports:{}};n[u][0].call(c.exports,function(r){var t=n[u][1][r];return o(t||r)},c,c.exports,r,n,t,e)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<e.length;u++)o(e[u]);return o}({1:[function(r,n,t){n.exports=function(){function n(r,n){return n(r.toLowerCase().replace(/-/g,""))}function t(r,n){for(var t,e=n(r),o="",i=0,u=32-e.length;i<u;++i)o+="0";return t=(o+e).match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/),[t[1],t[2],t[3],t[4],t[5]].join("-")}function e(r){var e=r||u,f=o(o.HEX,e),a=o(e,o.HEX);return{new:function(){return n(i(),f)},uuid:i,fromUUID:function(r){return n(r,f)},toUUID:function(r){return t(r,a)},alphabet:e}}var o=r("any-base"),i=r("uuid/v4"),u="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ";return e.constants={flickrBase58:u,cookieBase90:"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~"},e.uuid=i,e}()},{"any-base":2,"uuid/v4":6}],2:[function(r,n,t){function e(r,n){var t=new o(r,n);return function(r){return t.convert(r)}}var o=r("./src/converter");e.BIN="01",e.OCT="01234567",e.DEC="0123456789",e.HEX="0123456789abcdef",n.exports=e},{"./src/converter":3}],3:[function(r,n,t){"use strict";function e(r,n){if(!(r&&n&&r.length&&n.length))throw new Error("Bad alphabet");this.srcAlphabet=r,this.dstAlphabet=n}e.prototype.convert=function(r){var n,t,e,o={},i=this.srcAlphabet.length,u=this.dstAlphabet.length,f=r.length,a="";if(this.srcAlphabet===this.dstAlphabet)return r;for(n=0;n<f;n++)o[n]=this.srcAlphabet.indexOf(r[n]);do{for(t=0,e=0,n=0;n<f;n++)(t=t*i+o[n])>=u?(o[e++]=parseInt(t/u,10),t%=u):e>0&&(o[e++]=0);f=e,a=this.dstAlphabet[t]+a}while(0!=e);return a},n.exports=e},{}],4:[function(r,n,t){function e(r,n){var t=n||0,e=o;return e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+"-"+e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]+e[r[t++]]}for(var o=[],i=0;i<256;++i)o[i]=(i+256).toString(16).substr(1);n.exports=e},{}],5:[function(r,n,t){var e,o=global.crypto||global.msCrypto;if(o&&o.getRandomValues){var i=new Uint8Array(16);e=function(){return o.getRandomValues(i),i}}if(!e){var u=new Array(16);e=function(){for(var r,n=0;n<16;n++)0==(3&n)&&(r=4294967296*Math.random()),u[n]=r>>>((3&n)<<3)&255;return u}}n.exports=e},{}],6:[function(r,n,t){function e(r,n,t){var e=n&&t||0;"string"==typeof r&&(n="binary"==r?new Array(16):null,r=null);var u=(r=r||{}).random||(r.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,n)for(var f=0;f<16;++f)n[e+f]=u[f];return n||i(u)}var o=r("./lib/rng"),i=r("./lib/bytesToUuid");n.exports=e},{"./lib/bytesToUuid":4,"./lib/rng":5}]},{},[1])(1)});

@@ -20,3 +20,3 @@ /**

function shortenUUID (longId, translator) {
return translator(longId.replace(/-/g,''));
return translator(longId.toLowerCase().replace(/-/g,''));
}

@@ -23,0 +23,0 @@

{
"name": "short-uuid",
"version": "2.3.3",
"version": "2.3.4",
"description": "Create and translate standard UUIDs with shorter formats.",

@@ -35,3 +35,3 @@ "main": "index.js",

"devDependencies": {
"codeclimate-test-reporter": "^0.4.0",
"codeclimate-test-reporter": "^0.5.0",
"grunt": "^1.0.1",

@@ -38,0 +38,0 @@ "grunt-browserify": "^5.0.0",

@@ -9,3 +9,3 @@ # short-uuid

## v2.3.3
## v2.3.4

@@ -21,4 +21,9 @@ short-uuid provides RFC4122 v4-compliant UUIDs,

2.3.2 merges a TypeScript definition from [alexturek](https://github.com/alexturek).
2.3.3 fixes missing /dist folder from the npm module.
2.3.3 fixes missing /dist folder from the npm module.
2.3.4 corrects the behavior for UUIDs with uppercase letters.
**Prior to 2.3.4, passing a UUID with capital letters would cause an incorrect conversion.**
All UUIDs are now converted to lowercase before translation.
UUIDs generated by the `uuid` library were always lowercase. This was a test case miss.
### v2.2.0 Deprecated

@@ -25,0 +30,0 @@ 2.2.0 incorrectly added Snyk as a production dependency. It has been deprecated.

# Revisions
# v2.3.4
2.3.4 corrects the behavior for UUIDs with uppercase letters.
**Prior to 2.3.4, passing a UUID with capital letters would cause an incorrect conversion.**
All UUIDs are now converted to lowercase before translation.
UUIDs generated by the `uuid` library were always lowercase. This was a test case miss.
# v2.3.3

@@ -4,0 +12,0 @@

@@ -57,5 +57,3 @@ /**

var uu, f58, f90;
for (var i = 0; i < 10; i++) {
var cycle = function(test) {
uu = short.uuid();

@@ -70,4 +68,21 @@

it('should translate back from multiple bases', function(){
test();
};
var uu, f58, f90, i, action;
it('should generate valid UUIDs', function(){
action = function() {
assert.ok(validUUIDRegex.test(uu), 'UUID is valid');
};
for (i = 0; i < 10; i++) {
cycle(action);
}
});
it('should translate back from multiple bases', function(){
action = function() {
assert.equal(b58.toUUID(f58), uu, 'Translated b58 matches original');

@@ -78,8 +93,20 @@ assert.ok(validUUIDRegex.test(b58.toUUID(f58)), 'Translated UUID is valid');

assert.ok(validUUIDRegex.test(b90.toUUID(f90)), 'Translated UUID is valid');
});
};
it('should return a standard v4 uuid from instance.uuid()', function(){
for (i = 0; i < 10; i++) {
cycle(action);
}
});
it('should return a standard v4 uuid from instance.uuid()', function(){
action = function() {
assert.ok(validUUIDRegex.test(b58.uuid()), '.uuid() is a valid UUID');
});
}
};
for (i = 0; i < 10; i++) {
cycle(action);
}
});

@@ -99,2 +126,18 @@ it('should handle UUIDs that begin with zeros', function(){

it('should handle UUID with uppercase letters', function(){
var uuidWithUpper = '00000013-0000-1000-8000-0026BB765291',
uuidAllLower = uuidWithUpper.toLowerCase(),
upperB58 = b58.fromUUID(uuidWithUpper),
lowerB58 = b58.fromUUID(uuidAllLower),
upperBack = b58.toUUID(upperB58),
lowerBack = b58.toUUID(lowerB58);
assert.equal(upperB58, lowerB58, 'Translates uppercase letters in UUIDs');
assert.equal(upperBack, lowerBack, 'Translates back to UUID correctly');
assert.equal(upperBack, uuidAllLower, 'From uppercase matches original lowercase');
assert.equal(lowerBack, uuidAllLower, 'From lower matches original lowercase');
});
});

@@ -101,0 +144,0 @@

Sorry, the diff of this file is not supported yet

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