Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

html-truncate

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-truncate - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

2

package.json

@@ -6,3 +6,3 @@ {

"description": "truncate html text and keep tag safe",
"version": "0.3.0",
"version": "0.3.1",
"repository": {

@@ -9,0 +9,0 @@ "type": "git",

@@ -22,7 +22,9 @@ /**

, KEY_VALUE_REGEX = '(\\w+\\s*=\\s*"[^"]*"\\s*)*'
, SELF_CLOSE_REGEX = '\\s*\\/?\\s*'
, HTML_TAG_REGEX = new RegExp('<\\/?\\w+\\s*' + KEY_VALUE_REGEX + SELF_CLOSE_REGEX + '>')
, IMAGE_TAG_REGEX = new RegExp('<img\\s*' + KEY_VALUE_REGEX + SELF_CLOSE_REGEX + '>')
, IS_CLOSE_REGEX = '\\s*\\/?\\s*'
, CLOSE_REGEX = '\\s*\\/\\s*'
, SELF_CLOSE_REGEX = new RegExp('<\\/?\\w+\\s*' + KEY_VALUE_REGEX + CLOSE_REGEX + '>')
, HTML_TAG_REGEX = new RegExp('<\\/?\\w+\\s*' + KEY_VALUE_REGEX + IS_CLOSE_REGEX + '>')
, IMAGE_TAG_REGEX = new RegExp('<img\\s*' + KEY_VALUE_REGEX + IS_CLOSE_REGEX + '>')
, matches = true
, result, index, tail, tag;
, result, index, tail, tag, selfClose;

@@ -112,12 +114,19 @@ /**

} else {
tag = _getTag(result);
selfClose = SELF_CLOSE_REGEX.exec(result);
if ( ! selfClose) {
tag = _getTag(result);
items.push(tag);
items.push(tag);
}
}
content += result;
if (selfClose) {
content += selfClose[0];
} else {
content += result;
}
string = string.substring(index + result.length);
}
if (options.ellipsis) {
if (string.length > maxLength && options.ellipsis) {
content += options.ellipsis;

@@ -124,0 +133,0 @@ }

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