Socket
Socket
Sign inDemoInstall

node-readability

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-readability - npm Package Compare versions

Comparing version 0.9.0 to 0.10.0

test/test.html

4

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc