Skip to content

Commit

Permalink
fixed gbk issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Feb 25, 2020
1 parent c70303e commit c6d2b76
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ let Proxy = ({httpprefix, serverName, port, cookieDomainRewrite, locationReplace
logSave(`utf-8 text...`)
let originBody = gunzipped
body = gunzipped.toString('utf-8');
if (body.indexOf('="text/html; charset=gb') !== -1 ||
body.indexOf('=\'text/html; charset=gb') !== -1) {
if (body.indexOf(' charset=gb') !== -1) {
logSave(`gb2312 found...`)
body = iconv.decode(originBody, 'gbk')
gbFlag = true
Expand All @@ -206,8 +205,7 @@ let Proxy = ({httpprefix, serverName, port, cookieDomainRewrite, locationReplace
logSave(`utf-8 text...`)
let originBody = body
body = body.toString('utf-8');
if (body.indexOf('="text/html; charset=gb') !== -1 ||
body.indexOf('=\'text/html; charset=gb') !== -1) {
if (body.indexOf(' charset=gb') !== -1) {
logSave(`gb2312 found...`)
body = iconv.decode(originBody, 'gbk')
gbFlag = true
Expand Down
2 changes: 1 addition & 1 deletion test/siteproxylocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ test('reuters.com /article issue', async () => {
method: 'get',
url,
})
console.log(`${response.data}`)
// console.log(`${response.data}`)
expect(response.data.indexOf(`"url":"/article`)).toBe(-1)
}, 30000);

0 comments on commit c6d2b76

Please sign in to comment.