html-ellipsis
Advanced tools
Comparing version 1.1.0 to 1.1.1
/** | ||
* @module html-ellipsis | ||
* @version 1.0.0 | ||
* @version 1.1.1 | ||
* @exports htmlEllipsis | ||
* | ||
* @copyright 2014 Alex Gherghisan | ||
* @copyright 2015 Alex Gherghisan | ||
* @license MIT | ||
@@ -76,3 +76,3 @@ */ | ||
if (len <= maxLength) { | ||
return html; | ||
return html; | ||
} | ||
@@ -90,3 +90,6 @@ | ||
while (i < len && charCount < maxLength) { | ||
if (html[i] === '<') { | ||
var char = html.charAt(i); | ||
var charCode = html.charCodeAt(i); | ||
if (char === '<') { | ||
var tag = extractTag(html, i); | ||
@@ -107,2 +110,8 @@ | ||
} else { | ||
// if charCode is a high surrogate and if the string contains a low surrogate | ||
// then count the pair as a single character | ||
if (charCode >= 0xD800 && charCode <= 0xDBFF && i + 1 < len) { | ||
++i; | ||
} | ||
++charCount; | ||
@@ -126,2 +135,1 @@ ++i; | ||
})); | ||
{ | ||
"name": "html-ellipsis", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "truncates a html string without messing up the tags", | ||
"main": "html-ellipsis.js", | ||
"scripts": { | ||
"test": "node test/truncate.js", | ||
"lint": "node ./node_modules/.bin/jshint html-ellipsis.js" | ||
"test": "tape test/**/*.js", | ||
"lint": "jshint html-ellipsis.js", | ||
"uglify": "uglifyjs --mangle --compress --comments -- html-ellipsis.js > html-ellipsis.min.js && wc -c html-ellipsis.*js | head -2" | ||
}, | ||
@@ -20,3 +21,3 @@ "repository": { | ||
], | ||
"author": "Alex Gherghisan <alex.gherghisan@gmail.com>", | ||
"author": "Alex Gherghisan <alex@alexghr.me>", | ||
"license": "MIT", | ||
@@ -29,4 +30,5 @@ "bugs": { | ||
"jshint": "^2.5.6", | ||
"tape": "^3.0.0" | ||
"tape": "^3.0.0", | ||
"uglify-js": "^2.4.15" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# html-ellipsis | ||
# html-ellipsis [![html-ellipsis API Documentation](https://www.omniref.com/js/npm/html-ellipsis.png)](https://www.omniref.com/js/npm/html-ellipsis) [![Build Status](https://travis-ci.org/alexghr/html-ellipsis.svg)](https://travis-ci.org/alexghr/html-ellipsis) | ||
@@ -3,0 +3,0 @@ Truncates a html string without messing up HTML tags |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
0
7128
3
108