mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-19 18:42:34 +00:00
Execute unescapeHTML before encoding exturl
* See: https://github.com/next-theme/hexo-theme-next/issues/364
This commit is contained in:
parent
9a313b23c3
commit
d1bf101cc1
@ -3,6 +3,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { parse } = require('url');
|
const { parse } = require('url');
|
||||||
|
const { unescapeHTML } = require('hexo-util');
|
||||||
|
|
||||||
hexo.extend.filter.register('after_post_render', data => {
|
hexo.extend.filter.register('after_post_render', data => {
|
||||||
const { config } = hexo;
|
const { config } = hexo;
|
||||||
@ -25,9 +26,10 @@ hexo.extend.filter.register('after_post_render', data => {
|
|||||||
|
|
||||||
// Return encrypted URL with title.
|
// Return encrypted URL with title.
|
||||||
const title = match.match(/title="([^"]+)"/);
|
const title = match.match(/title="([^"]+)"/);
|
||||||
if (title) return `<span class="exturl" data-url="${Buffer.from(href).toString('base64')}" title="${title[1]}">${html}${exturlIcon}</span>`;
|
const encoded = Buffer.from(unescapeHTML(href)).toString('base64');
|
||||||
|
if (title) return `<span class="exturl" data-url="${encoded}" title="${title[1]}">${html}${exturlIcon}</span>`;
|
||||||
|
|
||||||
return `<span class="exturl" data-url="${Buffer.from(href).toString('base64')}">${html}${exturlIcon}</span>`;
|
return `<span class="exturl" data-url="${encoded}">${html}${exturlIcon}</span>`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user