Skip to content

Commit

Permalink
[Fix] Fixes version array and changes it to a const.
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman committed Sep 28, 2016
1 parent 7371add commit 20caf4b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ internals.String = class extends Any {
'uuidv5': '5'
};

let versions;
const versions = [];

if (guidOptions && guidOptions.version) {
if (!Array.isArray(guidOptions.version)) {
Expand All @@ -315,17 +315,14 @@ internals.String = class extends Any {

Hoek.assert(guidOptions.version.length >= 1, 'version must have at least 1 valid version specified');

versions = [];
for (let i = 0; i < guidOptions.version.length; ++i) {
let version = guidOptions.version[i];
Hoek.assert(typeof version === 'string', 'version at position ' + i + ' must be a string');
version = version.toLowerCase();
Hoek.assert(uuids[version], 'version at position ' + i + ' must be one of ' + Object.keys(uuids).join(', '));
Hoek.assert(versions.indexOf(version) === -1, 'version at position ' + i + ' must not be a duplicate');
versions.push(version);
}

// Make sure we have a set of versions
versions = Hoek.unique(versions);
}

const regex = /^([\[{\(]?)([0-9A-F]{8})([:-]?)([0-9A-F]{4})([:-]?)([0-9A-F]{4})([:-]?)([0-9A-F]{4})([:-]?)([0-9A-F]{12})([\]}\)]?)$/i;
Expand Down

0 comments on commit 20caf4b

Please sign in to comment.