We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4309fca commit 990c15aCopy full SHA for 990c15a
1 file changed
src/server/utils/file-form-service.js
@@ -11,19 +11,24 @@ import YAML from 'yaml'
11
* @returns string
12
*/
13
function uuid(seed) {
14
+ const uuidLen = 36
15
+ const firstSepIdx = 8
16
+ const secondSepIdx = 13
17
+ const thirdSepIdx = 18
18
+ const forthSepIdx = 23
19
const hash = crypto
20
.createHash('sha256')
21
.update(seed.toString())
22
.digest('hex')
- .substring(0, 36)
23
+ .substring(0, uuidLen)
24
const chars = hash.split('')
25
- chars[8] = '-'
- chars[13] = '-'
- chars[14] = '4'
- chars[18] = '-'
- chars[19] = '8'
26
- chars[23] = '-'
+ chars[firstSepIdx] = '-'
27
+ chars[secondSepIdx] = '-'
28
+ chars[secondSepIdx + 1] = '4'
29
+ chars[thirdSepIdx] = '-'
30
+ chars[thirdSepIdx + 1] = '8'
31
+ chars[forthSepIdx] = '-'
32
33
return chars.join('')
34
}
0 commit comments