fix(ck): 修复令牌中的 /r 被误拆为换行并升级至 0.5.6

This commit is contained in:
yml2213
2026-11-12 13:16:48 +08:00
parent ceb31ed712
commit 90717d66d1
8 changed files with 17 additions and 31 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "huya-go-frontend",
"version": "0.5.5",
"version": "0.5.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "huya-go-frontend",
"version": "0.5.5",
"version": "0.5.6",
"dependencies": {
"antd": "^5.26.2",
"lucide-react": "^0.468.0",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "huya-go-frontend",
"private": true,
"version": "0.5.5",
"version": "0.5.6",
"type": "module",
"scripts": {
"dev": "vite --host 127.0.0.1",
+1 -1
View File
@@ -1 +1 @@
a9d40923be4354a749fbbe0c2b9f924e
2ad4bd69c55591396cf10c56499e2f56
+5 -10
View File
@@ -264,6 +264,7 @@ type ScoreResult = {
type UserPrizeInfo = {
id?: number
name?: string
account?: string
score?: number
new_score?: number
status?: number
@@ -279,6 +280,7 @@ type RecordResult = {
uid: number
records?: UserPrizeInfo[]
resp?: {
status?: number
msg?: string
}
error?: string
@@ -670,16 +672,9 @@ function writeSavedPrizeCache(
}
function normalizeCookieText(text: string): string {
const normalized = text
return text
.replace(/\r\n?/g, '\n')
.replace(/\\r\\n|\\r|\\n/g, '\n')
const withLineBreaks =
normalized.includes('\n') || !/\/r\/n|\/r/.test(normalized)
? normalized
: normalized.replace(/\/r\/n|\/r|\/n/g, '\n')
return withLineBreaks
.split('\n')
.map((line) => line.trim())
.filter(Boolean)
@@ -1995,7 +1990,7 @@ export default function Dashboard() {
minWidth: 200,
ellipsis: true,
render: (name, row) => (
<Space orientation="horizontal" size={6}>
<Space size={6}>
{row.img ? (
<img
src={row.img}
@@ -2807,7 +2802,7 @@ export default function Dashboard() {
title: '商品',
dataIndex: 'name',
render: (name, r) => (
<Space orientation="horizontal" size={8}>
<Space size={8}>
{r.img ? (
<img
src={r.img}
+1 -10
View File
@@ -988,22 +988,13 @@ func splitCookieLines(cookieText string) []cookieLine {
}
func normalizeCookieText(cookieText string) string {
normalized := strings.NewReplacer(
return strings.NewReplacer(
"\r\n", "\n",
"\r", "\n",
`\r\n`, "\n",
`\r`, "\n",
`\n`, "\n",
).Replace(cookieText)
if strings.Contains(normalized, "\n") ||
(!strings.Contains(normalized, "/r/n") && !strings.Contains(normalized, "/r")) {
return normalized
}
return strings.NewReplacer(
"/r/n", "\n",
"/r", "\n",
"/n", "\n",
).Replace(normalized)
}
func requestContext(timeoutSec int) (context.Context, context.CancelFunc) {
+3 -3
View File
@@ -24,9 +24,9 @@ func TestSplitCookieLinesNormalizesLineBreaks(t *testing.T) {
want: []string{"ck-a", "ck-b", "ck-c", "ck-d"},
},
{
name: "slash_r_line_breaks",
input: "ck-a/r/nck-b/rck-c/nck-d",
want: []string{"ck-a", "ck-b", "ck-c", "ck-d"},
name: "slash_r_and_n_inside_token_are_preserved",
input: "yyuid=1; udb_cred=abc/rrZT/nXYZ",
want: []string{"yyuid=1; udb_cred=abc/rrZT/nXYZ"},
},
{
name: "slash_n_only_is_preserved",
+3 -3
View File
@@ -5,10 +5,10 @@ package version
//
// 构建时可用 ldflags 覆盖(构建脚本就是这么做的):
//
// go build -ldflags "-X huya-go/internal/version.Version=0.5.4"
var Version = "0.5.5"
// go build -ldflags "-X huya-go/internal/version.Version=0.5.6"
var Version = "0.5.6"
// Display 返回带 v 前缀的展示版本号,例如 v0.5.4。
// Display 返回带 v 前缀的展示版本号,例如 v0.5.6。
func Display() string {
return "v" + Version
}
+1 -1
View File
@@ -9,7 +9,7 @@
"info": {
"companyName": "huya-go",
"productName": "虎牙抢购助手",
"productVersion": "0.5.5",
"productVersion": "0.5.6",
"copyright": "",
"comments": "虎牙活动积分兑换/抢购工具"
}