You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

hexo-util

Package Overview
Dependencies
Maintainers
8
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.1 to 1.4.0

lib/unescape_html.js

4

lib/escape_html.js
'use strict';
const unescapeHTML = require('./unescape_html');
const htmlEntityMap = {

@@ -15,2 +17,4 @@ '&': '&',

str = unescapeHTML(str);
// http://stackoverflow.com/a/12034334

@@ -17,0 +21,0 @@ return str.replace(/[&<>"'/]/g, a => htmlEntityMap[a]);

@@ -27,2 +27,3 @@ 'use strict';

if (i.match(regexUrl)) result += ` ${escapeHTML(i)}="${encodeURL(attrs[i])}"`;
else if (attrs[i] === true || i === attrs[i]) result += ` ${escapeHTML(i)}`;
else if (i.match(/srcset$/i)) result += ` ${escapeHTML(i)}="${encSrcset(attrs[i])}"`;

@@ -29,0 +30,0 @@ else result += ` ${escapeHTML(i)}="${escapeHTML(String(attrs[i]))}"`;

@@ -27,3 +27,4 @@ 'use strict';

exports.truncate = require('./truncate');
exports.unescapeHTML = require('./unescape_html');
exports.url_for = require('./url_for');
exports.wordWrap = require('./word_wrap');

2

package.json
{
"name": "hexo-util",
"version": "1.3.1",
"version": "1.4.0",
"description": "Utilities for Hexo.",

@@ -5,0 +5,0 @@ "main": "lib/index",

@@ -102,2 +102,11 @@ # hexo-util

``` js
escapeHTML('<p>Hello "world".</p>')
// &lt;p&gt;Hello &quot;world&quot;.&lt;&#x2F;p&gt;
/* support escaped characters */
escapeHTML('&lt;foo>bar</foo&gt;')
// &lt;foo&gt;bar&lt;&#x2F;foo&gt;
```
### escapeRegex(str)

@@ -211,2 +220,6 @@

// <style>p { content: "<"; background: url("b%C3%A1r.jpg"); }</style>
/* support script tag with async/defer */
htmlTag('script', {src: '/foo.js', async: true}, '')
// <script src="/foo.js" async></script>
```

@@ -356,2 +369,11 @@

### unescapeHTML(str)
Unescapes HTML entities in a string.
``` js
unescapeHTML('&lt;p&gt;Hello &quot;world&quot;.&lt;&#x2F;p&gt;')
// <p>Hello "world".</p>
```
### url_for(path, [option])

@@ -397,3 +419,3 @@

Following utilities require `bind(hexo)` / `bind(this)` to parse the user config when initializing:
Following utilities require `bind(hexo)` / `bind(this)` / `call(hexo, input)` / `call(this, input)` to parse the user config when initializing:
- [`full_url_for()`](#full_url_forpath)

@@ -403,3 +425,3 @@ - [`url_for()`](#url_forpath)

Below examples demonstrate four approaches of creating a [helper](https://hexo.io/api/helper) (each example is separated by `/******/`),
Below examples demonstrate different approaches to creating a [helper](https://hexo.io/api/helper) (each example is separated by `/******/`),

@@ -439,2 +461,12 @@ ``` js

/******/
// Function.call() approach also works
const {url_for} = require('hexo-util');
module.exports = function(str) {
return url_for.call(this, str);
}
hexo.extend.helper.register('test_url', require('./test_url'));
/******/
// Separating functions into individual files

@@ -441,0 +473,0 @@ // Each file has multiple functions

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc