Skip to content

Commit 4a9b6ce

Browse files
committed
refactor: fix lint on public/js/utils.js
Signed-off-by: BoHong Li <[email protected]>
1 parent fffefcc commit 4a9b6ce

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

public/js/utils.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
import base64url from 'base64url'
22

3-
let uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
3+
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
44

55
export function checkNoteIdValid (id) {
6-
let result = id.match(uuidRegex)
7-
if (result && result.length === 1) {
8-
return true
9-
} else {
10-
return false
11-
}
6+
const result = id.match(uuidRegex)
7+
return !!(result && result.length === 1)
128
}
139

1410
export function encodeNoteId (id) {
1511
// remove dashes in UUID and encode in url-safe base64
16-
let str = id.replace(/-/g, '')
17-
let hexStr = Buffer.from(str, 'hex')
12+
const str = id.replace(/-/g, '')
13+
const hexStr = Buffer.from(str, 'hex')
1814
return base64url.encode(hexStr)
1915
}
2016

2117
export function decodeNoteId (encodedId) {
2218
// decode from url-safe base64
23-
let id = base64url.toBuffer(encodedId).toString('hex')
19+
const id = base64url.toBuffer(encodedId).toString('hex')
2420
// add dashes between the UUID string parts
25-
let idParts = []
21+
const idParts = []
2622
idParts.push(id.substr(0, 8))
2723
idParts.push(id.substr(8, 4))
2824
idParts.push(id.substr(12, 4))

0 commit comments

Comments
 (0)