diff --git a/lib/body.js b/lib/body.js
index 9abe6c9..8a00c55 100644
--- a/lib/body.js
+++ b/lib/body.js
@@ -293,6 +293,12 @@ const convertBody = (buffer, headers) => {
if (!res && str) {
res = / {
t.equal(await b.textConverted(), s)
})
+ t.test('html4 meta tag reversed', async t => {
+ const s = '
中文L
'
+ const b = new Body(convert(s, 'gbk'))
+ t.equal(await b.textConverted(), s)
+ })
+
+
t.test('html5 meta tag', async t => {
const s = '中文
'
const b = new Body(convert(s, 'gbk'))
diff --git a/test/fixtures/server.js b/test/fixtures/server.js
index f46f772..3b67060 100644
--- a/test/fixtures/server.js
+++ b/test/fixtures/server.js
@@ -164,6 +164,12 @@ class TestServer {
res.end(convert('中文
', 'gb2312'))
}
+ if (p === '/encoding/gb2312-reverse') {
+ res.statusCode = 200;
+ res.setHeader('Content-Type', 'text/html');
+ res.end(convert('中文
', 'gb2312'));
+ }
+
if (p === '/encoding/shift-jis') {
res.statusCode = 200
res.setHeader('Content-Type', 'text/html; charset=Shift-JIS')
diff --git a/test/index.js b/test/index.js
index 86894d1..93639eb 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1767,6 +1767,14 @@ t.test('with optional `encoding`', t => {
})
}))
+ t.test('encoding decode, html4 detect reverse http-equiv', t =>
+ fetch(`${base}encoding/gb2312-reverse`).then(res => {
+ t.equal(res.status, 200)
+ return res.textConverted().then(result => {
+ t.equal(result, '中文
')
+ })
+ }))
+
t.test('default to utf8 encoding', t =>
fetch(`${base}encoding/utf8`).then(res => {
t.equal(res.status, 200)