优化 b64u 的定义,用 . 代替 -,因为 - 和空格一样导致 css white-space 自动换行
This commit is contained in:
parent
48a3652f39
commit
ca97a2af62
@ -52,14 +52,14 @@ export default {
|
|||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
address2colorB64u(address){ // TIC address should be in b64u format, i.e. base64 for url (+ to -, / to _)
|
address2colorB64u(address){ // TIC address should be in b64u format, i.e. base64 for url (+ to ., / to _)
|
||||||
if (/^[0-9a-zA-Z\-_]+$/.test(address)){
|
if (/^[0-9a-zA-Z\._]+$/.test(address)){
|
||||||
// TIC地址被精心设计为24字节,32个b64字符,不需要填充
|
// TIC地址被精心设计为24字节,32个b64字符,不需要填充
|
||||||
// let len=address.length
|
// let len=address.length
|
||||||
// let rest = len % 4
|
// let rest = len % 4
|
||||||
// let fullLength = len + (4-(rest?rest:4))
|
// let fullLength = len + (4-(rest?rest:4))
|
||||||
// address = address.padEnd(fullLength, 'A') // 在 b64 里,'00'字节是A.
|
// address = address.padEnd(fullLength, 'A') // 在 b64 里,'00'字节是A.
|
||||||
let colorArray = address.match(/[0-9A-Za-z\-_]{4}/g)
|
let colorArray = address.match(/[0-9A-Za-z\._]{4}/g)
|
||||||
switch(this.block){
|
switch(this.block){
|
||||||
case "2": colorArray.splice(1, colorArray.length-2)
|
case "2": colorArray.splice(1, colorArray.length-2)
|
||||||
case "4": colorArray.splice(2, colorArray.length-4)
|
case "4": colorArray.splice(2, colorArray.length-4)
|
||||||
@ -72,8 +72,8 @@ export default {
|
|||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
b64u2hex(b64u){
|
b64u2hex(b64u){
|
||||||
if (/^[0-9a-zA-Z\-_]+$/.test(b64u)){
|
if (/^[0-9a-zA-Z\._]+$/.test(b64u)){
|
||||||
let b64 = b64u.replace(/\-/g, '+').replace(/_/g, '/')
|
let b64 = b64u.replace(/\./g, '+').replace(/_/g, '/')
|
||||||
return Buffer.from(b64, 'base64').toString('hex')
|
return Buffer.from(b64, 'base64').toString('hex')
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
|
Loading…
Reference in New Issue
Block a user