Skip to content

Commit 990c15a

Browse files
No maginc numbers
1 parent 4309fca commit 990c15a

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/server/utils/file-form-service.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,24 @@ import YAML from 'yaml'
1111
* @returns string
1212
*/
1313
function uuid(seed) {
14+
const uuidLen = 36
15+
const firstSepIdx = 8
16+
const secondSepIdx = 13
17+
const thirdSepIdx = 18
18+
const forthSepIdx = 23
1419
const hash = crypto
1520
.createHash('sha256')
1621
.update(seed.toString())
1722
.digest('hex')
18-
.substring(0, 36)
23+
.substring(0, uuidLen)
1924
const chars = hash.split('')
2025

21-
chars[8] = '-'
22-
chars[13] = '-'
23-
chars[14] = '4'
24-
chars[18] = '-'
25-
chars[19] = '8'
26-
chars[23] = '-'
26+
chars[firstSepIdx] = '-'
27+
chars[secondSepIdx] = '-'
28+
chars[secondSepIdx + 1] = '4'
29+
chars[thirdSepIdx] = '-'
30+
chars[thirdSepIdx + 1] = '8'
31+
chars[forthSepIdx] = '-'
2732

2833
return chars.join('')
2934
}

0 commit comments

Comments
 (0)