From 8335caac4f773fb40ca8adbc546b1430aa4f299e Mon Sep 17 00:00:00 2001 From: Brock Allen Date: Sat, 9 Mar 2019 15:52:23 -0500 Subject: [PATCH] remove dashes from guid for random API --- src/random.js | 2 +- test/unit/random.spec.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/random.js b/src/random.js index b43e0b1f..774fbbf0 100644 --- a/src/random.js +++ b/src/random.js @@ -5,5 +5,5 @@ var uuid4 = require('uuid/v4') */ export default function random() { - return uuid4() + return uuid4().replace(/-/g, ''); } diff --git a/test/unit/random.spec.js b/test/unit/random.spec.js index ddb99eb5..050cb301 100644 --- a/test/unit/random.spec.js +++ b/test/unit/random.spec.js @@ -1,11 +1,13 @@ import random from '../../src/random' -const pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/ +const pattern = /^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/ +//const pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/ describe('random', function() { - it('should return a valid RFC4122 v4 guid', function(){ + it('should return a valid RFC4122 v4 guid (sans dashes)', function(){ const rnd = random() + console.log(rnd); rnd.should.match(pattern) }) })