node-readability
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"name": "node-readability", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"author": "Zihua Li", | ||
@@ -22,3 +22,3 @@ "description": "Turning any web page into a clean view.", | ||
"dependencies": { | ||
"jsdom": "0.11.1", | ||
"jsdom": "^1.0.3", | ||
"request": "~2.40.0", | ||
@@ -25,0 +25,0 @@ "encoding": "~0.1.7" |
@@ -95,2 +95,6 @@ # Readability | ||
## Why not Cheerio | ||
This lib is using jsdom to parser HTML instead of cheerio because some data such as image size and element visibility isn't able to acquire when using cheerio, which will significantly affect the result. | ||
## Contributors | ||
@@ -97,0 +101,0 @@ |
@@ -200,4 +200,10 @@ var jsdom = require('jsdom'); | ||
if (errors) return callback(errors); | ||
if (!window.document.body) return callback(new Error('No body tag was found.')); | ||
if (errors) { | ||
window.close(); | ||
return callback(errors); | ||
} | ||
if (!window.document.body) { | ||
window.close(); | ||
return callback(new Error('No body tag was found.')); | ||
} | ||
// add meta information to callback | ||
@@ -204,0 +210,0 @@ callback(null, new Readability(window.document, options), meta); |
require('./mock-helpers.js'); | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var read = require('../src/readability'); | ||
var filePath = path.join(__dirname, 'test.html'); | ||
describe('charset', function () { | ||
describe('setted in the html', function() { | ||
it('should convert the page to utf-8', function(done) { | ||
read('http://tech.sina.com.cn/it/2014-01-16/04049100515.shtml', function(err, read) { | ||
read.content.should.include('谷歌'); | ||
read.title.should.include('谷歌'); | ||
done(); | ||
}); | ||
describe('setted in the html', function () { | ||
it('should convert the page to utf-8', function (done) { | ||
fs.readFile(filePath, {encoding: 'utf-8'}, function (err, html) { | ||
read(html, function (err, read) { | ||
read.content.should.include('谷歌'); | ||
read.title.should.include('谷歌'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -13,9 +13,2 @@ require('./mock-helpers.js'); | ||
it('should throw when missing body tag', function(done) { | ||
read('<html><head><title>hi</title></head>hi!</html>', function(err, read) { | ||
err.message.should.equal('No body tag was found.'); | ||
done(); | ||
}); | ||
}); | ||
it('should not resolve the url', function(done) { | ||
@@ -22,0 +15,0 @@ read('<html><body><img src="image.png"></a></body></html>', function(err, read) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3687270
17
1254
110
3
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedbrowser-request@0.3.3(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjsdom@1.5.0(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addednwmatcher@1.4.4(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedparse5@1.5.1(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.9.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedjsdom@0.11.1(transitive)
- Removednwmatcher@1.3.9(transitive)
- Removedtldts@6.1.48(transitive)
- Removedtldts-core@6.1.48(transitive)
- Removedtough-cookie@5.0.0(transitive)
Updatedjsdom@^1.0.3