is-html
Advanced tools
Comparing version 1.1.0 to 2.0.0
17
index.js
'use strict'; | ||
var htmlTags = require('html-tags'); | ||
const htmlTags = require('html-tags'); | ||
var basic = /\s?<!doctype html>|(<html\b[^>]*>|<body\b[^>]*>|<x-[^>]+>)+/i; | ||
const basic = /\s?<!doctype html>|(<html\b[^>]*>|<body\b[^>]*>|<x-[^>]+>)+/i; | ||
const full = new RegExp(htmlTags.map(tag => `<${tag}\\b[^>]*>`).join('|'), 'i'); | ||
var full = new RegExp(htmlTags.map(function (el) { | ||
return '<' + el + '\\b[^>]*>'; | ||
}).join('|'), 'i'); | ||
module.exports = function (str) { | ||
if (basic.test(str)) { | ||
return true; | ||
} | ||
return full.test(str); | ||
}; | ||
module.exports = string => basic.test(string) || full.test(string); |
{ | ||
"name": "is-html", | ||
"version": "1.1.0", | ||
"description": "Check if a string is HTML", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-html", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"html", | ||
"detect", | ||
"check", | ||
"is", | ||
"tags", | ||
"elements", | ||
"string" | ||
], | ||
"dependencies": { | ||
"html-tags": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
} | ||
"name": "is-html", | ||
"version": "2.0.0", | ||
"description": "Check if a string is HTML", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-html", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"html", | ||
"detect", | ||
"check", | ||
"is", | ||
"tags", | ||
"elements", | ||
"string" | ||
], | ||
"dependencies": { | ||
"html-tags": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -9,3 +9,3 @@ # is-html [![Build Status](https://travis-ci.org/sindresorhus/is-html.svg?branch=master)](https://travis-ci.org/sindresorhus/is-html) | ||
``` | ||
$ npm install --save is-html | ||
$ npm install is-html | ||
``` | ||
@@ -32,5 +32,2 @@ | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
Note: It does not detect deprecated HTML tags. |
Sorry, the diff of this file is not supported yet
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2487
2
5
32
1
+ Addedhtml-tags@3.3.1(transitive)
- Removedhtml-tags@1.2.0(transitive)
Updatedhtml-tags@^3.0.0