cheerio-httpcli
Advanced tools
Comparing version 0.6.7 to 0.6.8
@@ -0,1 +1,5 @@ | ||
# 0.6.8 (2016-04-12) | ||
* `$.html()`で取得するHTMLがエンティティ化されていたのを修正 | ||
# 0.6.7 (2016-04-07) | ||
@@ -2,0 +6,0 @@ |
@@ -14,2 +14,3 @@ /*jshint -W100*/ | ||
var path = require('path'); | ||
var cutil = require('./cheerio/util'); | ||
// os-localeは最初に実行した段階で結果をcacheに持つので | ||
@@ -413,2 +414,10 @@ // fetch()前に別のモジュールがos-localeを実行していた場合に | ||
// 素の$.htmlはエンティティ化してしまうので退避 | ||
result.$.entityHtml = result.$.html; | ||
result.$.html = function () { | ||
return cutil.decodeEntities( | ||
this.entityHtml.apply(this, Array.prototype.slice.call(arguments)) | ||
); | ||
}; | ||
// HTMLが取得できてもレスポンスステータスが20xでない場合(ソフト404など)はエラーとして処理する | ||
@@ -415,0 +424,0 @@ if (String(res.statusCode).substr(0, 2) !== '20') { |
{ | ||
"name": "cheerio-httpcli", | ||
"version": "0.6.7", | ||
"version": "0.6.8", | ||
"description": "http client module with cheerio & iconv(-lite) & promise", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,2 +5,4 @@ /*eslint-env mocha*/ | ||
var assert = require('power-assert'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var he = require('he'); | ||
@@ -91,2 +93,18 @@ var helper = require('./_helper'); | ||
}); | ||
describe('$.html', function () { | ||
it('元htmlにエンティティなし => そのまま取得', function (done) { | ||
cli.fetch(helper.url('auto', 'utf-8'), function (err, $, res, body) { | ||
assert($.html() === fs.readFileSync(path.join(__dirname, 'fixtures/auto/utf-8.html'), 'utf-8')); | ||
done(); | ||
}); | ||
}); | ||
it('元htmlにエンティティあり => 文字列に変換されている', function (done) { | ||
cli.fetch(helper.url('entities', 'sign'), function (err, $, res, body) { | ||
var html = he.decode(fs.readFileSync(path.join(__dirname, 'fixtures/entities/sign.html'), 'utf-8')); | ||
assert($.html() === html); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
351120
6179
6