New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

html-validator

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-validator - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

lib/filter-data.js

8

index.js

@@ -6,2 +6,3 @@ 'use strict'

const setupOptions = require('./lib/setup-options')
const filterData = require('./lib/filter-data')

@@ -35,2 +36,3 @@ module.exports = (options, callback) => {

const reqOpts = setupOptions(options)
const ignore = options.ignore

@@ -53,4 +55,8 @@ request(reqOpts, (error, response, result) => {

const data = options.format === 'json' ? JSON.parse(result) : result
var data = options.format === 'json' && !ignore ? JSON.parse(result) : result
if (ignore) {
data = filterData(data, ignore)
}
if (callback) {

@@ -57,0 +63,0 @@ return callback(null, data)

2

package.json
{
"name": "html-validator",
"version": "2.1.0",
"version": "2.2.0",
"description": "Validate html using validator.w3.org/nu",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -41,4 +41,6 @@ [![Build Status](https://travis-ci.org/zrrrzzt/html-validator.svg?branch=master)](https://travis-ci.org/zrrrzzt/html-validator)

**url** The url to the page you want to validate.
**url**/**data** The url to the page you want to validate or the data you want validated.
**ignore** String or array of strings you want the checker to remove in the response
#### Promise

@@ -173,3 +175,47 @@

**ignore** String or array of strings you want the checker to remove in the response. Requires format = text
### Promise
```JavaScript
const validator = require('html-validator')
const options = {
url: 'http://url-to-validate.com',
format: 'text',
ignore: 'Error: Stray end tag “div”.'
}
validator(options)
.then((data) => {
console.log(data)
})
.catch((error) => {
console.error(error)
})
```
#### Callback
```JavaScript
const validator = require('html-validator')
const options = {
url: 'http://url-to-validate.com',
format: 'text',
ignore: 'Error: Stray end tag “div”.'
}
validator(options, (error, data) => {
if (error) {
console.error(error)
}
console.log(data)
})
```
## Related
- [html-validator-cli](https://github.com/zrrrzzt/html-validator-cli) CLI for this module
- [html-validator-cli](https://github.com/zrrrzzt/html-validator-cli) CLI for this module
## License
[MIT](LICENSE)

@@ -120,1 +120,17 @@ 'use strict'

})
tap.test('Should get 0 error messages from invalid.html if ignored', (test) => {
const options = {
format: 'text',
data: fs.readFileSync('test/data/invalid.html'),
ignore: 'Error: Stray end tag “div”.'
}
validator(options)
.then((data) => {
tap.equal(false, /Error/.test(data), 'No errors found')
test.done()
})
.catch((error) => {
throw error
})
})

@@ -100,1 +100,16 @@ 'use strict'

})
tap.test('Should get 0 error messages from invalid.html if ignored', (test) => {
const options = {
format: 'text',
data: fs.readFileSync('test/data/invalid.html'),
ignore: 'Error: Stray end tag “div”.'
}
validator(options, (error, data) => {
if (error) {
throw error
}
tap.equal(false, /Error/.test(data), 'No errors found')
test.done()
})
})
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