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

react-htmlcontent

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-htmlcontent - npm Package Compare versions

Comparing version 1.2.6 to 1.2.8

dist/sanitizeHtml.js

27

dist/enhanceTypo.js

@@ -12,4 +12,4 @@ "use strict";

var containsHtmlPatt = /([^<]*)(<[A-z]*[^>]*>)(.*?)(<\/[A-z]+>)([^<]*)?/g;
var replaceHtmlContentPatt = /^([^<]{0,})(<([A-z])+[^>]*>)(.*)(<\/\3>)([^<]{0,})$/gi;
var containsHtmlPatt = /([^<]*)(<[A-z]*[^>]*>)(.*)(<\/[A-z]+>)([^<]*)?/gi;
var replaceHtmlContentPatt = /([^<]+\s*)?(<([A-z])+[^>]*\/?>)([^<]+\s*)(<\/\3>)(\s?[^<]+)?/gi;

@@ -20,3 +20,3 @@ function handleNbspBeforeTag(str) {

if (arr.length >= 2) {
return arr[arr.length - 1] === '' && arr[arr.length - 2].length === 1 ? '&nbsp;' : ' ';
return arr[arr.length - 1] === '' && arr[arr.length - 2].length === 1 || arr[0] === '' && arr[1].length === 1 ? '&nbsp;' : ' ';
} else {

@@ -33,8 +33,10 @@ return '';

if (containsHtmlPatt.test(data)) {
return data.replace(replaceHtmlContentPatt, function (_, beforeTag, startTag, tagName, body, endTag, afterTag) {
// console.log('-----------------------')
// console.log('str: ' + data)
// console.log('beforeTag: ' + beforeTag)
// console.log('body: ' + body)
// console.log('afterTag: ' + afterTag)
return data.replace(replaceHtmlContentPatt, function (_) {
var beforeTag = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var startTag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var tagName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var body = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
var endTag = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : '';
var afterTag = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : '';
if (containsHtmlPatt.test(body)) {

@@ -47,3 +49,5 @@ return enhanceTypo(body, locale, config);

} else {
return (0, _typography.default)(data, locale, config);
var before = data.replace(/^(\s*).+/, '$1');
var after = data.replace(/^.+(\s*)$/, '$1');
return "".concat(before).concat((0, _typography.default)(data, locale, config)).concat(after);
}

@@ -61,5 +65,2 @@ }

var r = enhanceTypo.apply(void 0, [str].concat(rest));
r = r.replace(/(\s|>)([A-z])\s<*/gi, '$1$2&nbsp;<');
console.log(r);
console.log(r.replace(/(\s|>)([A-z])\s<*/gi, '$1$2&nbsp;<'));
return r;

@@ -66,0 +67,0 @@ };

{
"name": "react-htmlcontent",
"version": "1.2.6",
"version": "1.2.8",
"description": "React HTMLContent Component",

@@ -27,2 +27,3 @@ "repository": {

"@babel/preset-env": "^7.5.4",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",

@@ -35,2 +36,3 @@ "@babel/preset-stage-0": "^7.0.0",

"chai": "^4.2.0",
"core-js": "3.1.4",
"enzyme": "^3.10.0",

@@ -46,5 +48,3 @@ "eslint": "^6.0.1",

"react-dom": "^16.8.6",
"sinon": "^7.3.2",
"@babel/preset-flow": "^7.0.0",
"core-js": "3.1.4"
"sinon": "^7.3.2"
},

@@ -54,3 +54,5 @@ "peerDependencies": {

},
"dependencies": {},
"dependencies": {
"sanitize-html": "^1.20.1"
},
"main": "dist/index.js",

@@ -57,0 +59,0 @@ "engines": {

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