From 42b6e0e915aeb62c678c2e3f864e3ea00f053880 Mon Sep 17 00:00:00 2001 From: Cno Date: Sat, 3 Sep 2022 15:32:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D4399=E6=98=B5=E7=A7=B0?= =?UTF-8?q?=E4=B8=AD=E5=85=A8=E8=A7=92=E5=AD=97=E7=AC=A6=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=A7=A3=E7=A0=81=E7=9A=84=E9=97=AE=E9=A2=98=20#13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + packages/main/modules/{GBKEncodeUri.ts => GBKUri.ts} | 7 ++++++- packages/main/modules/com4399.ts | 6 +++--- yarn.lock | 9 ++++++++- 4 files changed, 18 insertions(+), 5 deletions(-) rename packages/main/modules/{GBKEncodeUri.ts => GBKUri.ts} (68%) diff --git a/package.json b/package.json index b6f3573..209873b 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "axios": "^0.27.2", "cheerio": "^1.0.0-rc.10", "chrome-remote-interface": "^0.31.2", + "decodeuricomponent": "^0.3.1", "express": "^4.18.1", "iconv": "^3.0.1", "iconv-lite": "^0.6.3", diff --git a/packages/main/modules/GBKEncodeUri.ts b/packages/main/modules/GBKUri.ts similarity index 68% rename from packages/main/modules/GBKEncodeUri.ts rename to packages/main/modules/GBKUri.ts index 5f96bc9..2abe491 100644 --- a/packages/main/modules/GBKEncodeUri.ts +++ b/packages/main/modules/GBKUri.ts @@ -1,6 +1,7 @@ const Iconv = require('iconv').Iconv +const decodeUriComponent = require('decodeuricomponent'); -export default function (uri: string): string { +export function GBKEncodeUri(uri: string): string { let i = new Iconv('UTF-8', 'GBK'); let from = i.convert(uri); let rt = ''; @@ -16,3 +17,7 @@ export default function (uri: string): string { } return rt; } + +export function GBKDecodeUri(uri: string): string { + return decodeUriComponent(uri); +} \ No newline at end of file diff --git a/packages/main/modules/com4399.ts b/packages/main/modules/com4399.ts index ff7c4a8..26b13df 100644 --- a/packages/main/modules/com4399.ts +++ b/packages/main/modules/com4399.ts @@ -4,7 +4,7 @@ import {GameInfo} from '../../class'; import {BrowserWindow} from 'electron'; import iconv from 'iconv-lite'; import cheerio from 'cheerio'; -import GBKEncodeUri from "./GBKEncodeUri"; +import {GBKEncodeUri,GBKDecodeUri} from "./GBKUri"; let cookie: string | null = null let updateCookie: (cookie: string) => void @@ -364,10 +364,10 @@ function getNickName(cookie: string): Result { if (m == null) { return new Err("Error:Can't match nick name") } else { - return new Ok(decodeURI(m[0].split(/[=;]/)[1])) + return new Ok(GBKDecodeUri(m[0].split(/[=;]/)[1])) } } - return new Ok(decodeURI(m[0].split(/[=;]/)[1])) + return new Ok(GBKDecodeUri(m[0].split(/[=;]/)[1])) } //4399pvz专题页面的补丁函数 diff --git a/yarn.lock b/yarn.lock index d058a88..9f50c76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2035,6 +2035,13 @@ debug@4, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.4: dependencies: ms "2.1.2" +decodeuricomponent@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/decodeuricomponent/-/decodeuricomponent-0.3.1.tgz#4c3de9dd0fce86ca81da12ef0329e899d73e7c99" + integrity sha512-8PuirnWM7fdE54vRKoVT60RQlkFXgKsi7ToV4pdVbj9jc9qGSFt4P10Oi3UK+FPHZi+lhqRdPyG2QqhSfIhtQQ== + dependencies: + iconv-lite "^0.4.19" + decompress-response@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" @@ -3016,7 +3023,7 @@ iconv-corefoundation@^1.1.7: cli-truncate "^2.1.0" node-addon-api "^1.6.3" -iconv-lite@0.4.24: +iconv-lite@0.4.24, iconv-lite@^0.4.19: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==