mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Fix next_url: add new option to decodeURI
This commit is contained in:
parent
d1b22042e5
commit
b85201b9b8
@ -18,7 +18,7 @@
|
||||
{{ next_url(page.post_link, page.post_link, {title: page.title}) }}
|
||||
{%- else %}
|
||||
<strong>{{ __('post.copyright.link') + __('symbol.colon') }}</strong>
|
||||
{{ next_url(page.permalink, page.permalink, {title: page.title}) }}
|
||||
{{ next_url(page.permalink, page.permalink, {title: page.title}, true) }}
|
||||
{%- endif %}
|
||||
</li>
|
||||
<li class="post-copyright-license">
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
const { htmlTag } = require('hexo-util');
|
||||
const { parse } = require('url');
|
||||
|
||||
module.exports = function(path, text, options = {}) {
|
||||
module.exports = function(path, text, options = {}, decode = false) {
|
||||
const { config, theme } = this;
|
||||
const data = parse(path);
|
||||
const siteHost = parse(config.url).hostname || config.url;
|
||||
@ -50,5 +50,5 @@ module.exports = function(path, text, options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
return htmlTag(tag, attrs, decodeURI(text), false);
|
||||
return htmlTag(tag, attrs, decode ? decodeURI(text) : text, false);
|
||||
};
|
||||
|
||||
@ -32,6 +32,10 @@ describe('next-url', () => {
|
||||
nextUrl('https://theme-next.js.org', 'Text').should.eql('<a href="https://theme-next.js.org/" rel="noopener" target="_blank">Text</a>');
|
||||
});
|
||||
|
||||
it('decodeURI', () => {
|
||||
(() => nextUrl('https://theme-next.js.org', 'A % B')).should.not.throw();
|
||||
});
|
||||
|
||||
it('exturl enabled', () => {
|
||||
hexo.theme.exturl = true;
|
||||
const encoded = btoa('https://theme-next.js.org');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user