escape-goat

WebJar for escape-goat

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

escape-goat
Последняя версия

Последняя версия

2.1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

escape-goat
WebJar for escape-goat
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/sindresorhus/escape-goat

Скачать escape-goat

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/escape-goat/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>escape-goat</artifactId>
    <version>2.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/escape-goat/
implementation 'org.webjars.npm:escape-goat:2.1.1'
// https://jarcasting.com/artifacts/org.webjars.npm/escape-goat/
implementation ("org.webjars.npm:escape-goat:2.1.1")
'org.webjars.npm:escape-goat:jar:2.1.1'
<dependency org="org.webjars.npm" name="escape-goat" rev="2.1.1">
  <artifact name="escape-goat" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='escape-goat', version='2.1.1')
)
libraryDependencies += "org.webjars.npm" % "escape-goat" % "2.1.1"
[org.webjars.npm/escape-goat "2.1.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

escape-goat

Escape a string for use in HTML or the inverse

Build Status

Install

$ npm install escape-goat

Usage

const {htmlEscape, htmlUnescape} = require('escape-goat');

htmlEscape('🦄 & 🐐');
//=> '🦄 &amp; 🐐'

htmlUnescape('🦄 &amp; 🐐');
//=> '🦄 & 🐐'

htmlEscape('Hello <em>World</em>');
//=> 'Hello &lt;em&gt;World&lt;/em&gt;'

const url = 'https://sindresorhus.com?x="🦄"';

htmlEscape`<a href="${url}">Unicorn</a>`;
//=> '<a href="https://sindresorhus.com?x=&quot;🦄&quot;">Unicorn</a>'

const escapedUrl = 'https://sindresorhus.com?x=&quot;🦄&quot;';

htmlUnescape`URL from HTML: ${escapedUrl}`;
//=> 'URL from HTML: https://sindresorhus.com?x="🦄"'

API

htmlEscape(string)

Escapes the following characters in the given string argument: & < > " '

The function also works as a tagged template literal that escapes interpolated values.

htmlUnescape(htmlString)

Unescapes the following HTML entities in the given htmlString argument: &amp; &lt; &gt; &quot; &#39;

The function also works as a tagged template literal that unescapes interpolated values.

Tip

Ensure you always quote your HTML attributes to prevent possible XSS.

FAQ

Why yet another HTML escaping package?

I couldn't find one I liked that was tiny, well-tested, and had both .escape() and .unescape().

Версии библиотеки

Версия
2.1.1