Commit e9057621 authored by 郑磊's avatar 郑磊

当取到的token无效时继续取下一个位置

parent ec74e6b8
...@@ -48,15 +48,25 @@ export function parseToken(): TokenData | undefined { ...@@ -48,15 +48,25 @@ export function parseToken(): TokenData | undefined {
if (token) { if (token) {
//先尝试解码,如果失败则使用明文 //先尝试解码,如果失败则使用明文
try { try {
const value = decodeToken(token)
if (!value) {
throw new Error()
}
return { return {
token: decodeToken(token), token: value,
source: 'hash_encoded', source: 'hash_encoded',
} }
} catch (e: unknown) { } catch (e: unknown) {
return { try {
token: decodeToken(token), const value = decodeToken(token)
source: 'hash_raw', if (!value) {
} throw new Error()
}
return {
token: value,
source: 'hash_raw',
}
} catch (e: unknown) {}
} }
} }
} }
...@@ -68,15 +78,25 @@ export function parseToken(): TokenData | undefined { ...@@ -68,15 +78,25 @@ export function parseToken(): TokenData | undefined {
if (token) { if (token) {
//先尝试解码,如果失败则使用明文 //先尝试解码,如果失败则使用明文
try { try {
const value = decodeToken(token)
if (!value) {
throw new Error()
}
return { return {
token: decodeToken(token), token: value,
source: 'url_encoded', source: 'url_encoded',
} }
} catch (e: unknown) { } catch (e: unknown) {
return { try {
token: decodeToken(token), const value = decodeToken(token)
source: 'url_raw', if (!value) {
} throw new Error()
}
return {
token: value,
source: 'url_raw',
}
} catch (e: unknown) {}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment