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

html-template-tag

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-template-tag - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var _htmlEs6cape=require("html-es6cape");var _htmlEs6cape2=_interopRequireDefault(_htmlEs6cape);exports["default"]=function(literals){for(var _len=arguments.length,substs=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){substs[_key-1]=arguments[_key]}return literals.raw.reduce(function(acc,lit,i){var subst=substs[i-1];if(Array.isArray(subst)){subst=subst.join("")}else if(acc.endsWith("$")){acc=acc.slice(0,-1)}else{subst=(0,_htmlEs6cape2["default"])(subst)}return acc+subst+lit})};module.exports=exports["default"];
"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}var _htmlEs6cape=require("html-es6cape");var _htmlEs6cape2=_interopRequireDefault(_htmlEs6cape);exports["default"]=function(literals){for(var _len=arguments.length,substs=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){substs[_key-1]=arguments[_key]}return literals.raw.reduce(function(acc,lit,i){var subst=substs[i-1];if(Array.isArray(subst)){subst=subst.join("")}else if(literals.raw[i-1]&&literals.raw[i-1].endsWith("$")){acc=acc.slice(0,-1)}else{subst=(0,_htmlEs6cape2["default"])(subst)}return acc+subst+lit})};module.exports=exports["default"];
{
"name": "html-template-tag",
"version": "2.0.0",
"version": "3.0.0",
"description": "ES6 Tagged Template for compiling HTML template strings.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -10,3 +10,3 @@ // Inspired on http://www.2ality.com/2015/01/template-strings-html.html#comment-2078932192

subst = subst.join("");
} else if (acc.endsWith('$')) {
} else if (literals.raw[i - 1] && literals.raw[i - 1].endsWith("$")) {
// If the interpolation is preceded by a dollar sign,

@@ -13,0 +13,0 @@ // substitution is considered safe and will not be escaped

@@ -39,2 +39,12 @@ import {expect} from "chai";

it("should escape HTML special characters if previous substituition ended with $", () => {
let insertedDollar = "I :heart: $";
let unsafeString = " & €";
let emptyString = "";
expect(html`${insertedDollar}${unsafeString}!`).to.equal("I :heart: $ &amp; €!");
expect(html`${insertedDollar}${emptyString}${unsafeString}!`).to.equal("I :heart: $ &amp; €!");
expect(html`${insertedDollar}$${emptyString}${unsafeString}!`).to.equal("I :heart: $ &amp; €!");
expect(html`$${insertedDollar}${emptyString}${unsafeString}!`).to.equal("I :heart: $ &amp; €!");
})
it("should generate valid HTML with an array of values", () => {

@@ -41,0 +51,0 @@ let names = ["Megan", "Tiphaine", "Florent", "Hoan"];

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