fix(helpers, tag plugins): encode url by default#3710
fix(helpers, tag plugins): encode url by default#3710curbengh merged 14 commits intohexojs:masterfrom
Conversation
|
Depending on use case, |
|
|
|
Should we re-implement those helper using For example: // url_for.js
'use strict';
module.exports = function (path = '/', options) {
const url_for = require('hexo-util').url_for.bind(this);
return url_for(path, options)
}; |
Definitely, once hexo-util v1.2.0 is published. To be refactored (in a separate PR):
|
|
Ready to review. Just realized path is encoded twice if it's already encode (/foo/bar%20baz -> /foo/bar%25%20baz). Pending hexojs/hexo-util#92 |
|
WIP, needs to utilize Edit: refactored. |
|
Pending hexojs/hexo-util#92 & hexojs/hexo-util#94 to avoid encoding |
c5e60b4 to
cc23ba1
Compare
|
I have no idea why the test on AppVeyor failed while the test on Travis CI successed. |
The test failure shows the actual is "/foo%5Cbar" where This PR replaces Seems to resolve it, now left double-encoding issue. Looks like full_url_for() and url_for() currently don't support Windows path. Perhaps adding url.resolve() in those functions can help. Edit: url.resolve() in full_url_for() wouldn't help const { resolve } = require('url')
console.log(resolve('http://example.com/blog/', 'abc\hey\index.html'))
// http://example.com/blog/abcheyindex.htmlAnyhow, Windows path may not be applicable for full_url_for() / url_for(). |
8553da7 to
00f6141
Compare
|
html_tag of hexo-util needs to be updated for mail_to helper compatibility. Located the issue: const { parse } = require('url')
console.log(parse('mailto:abc@example.com'))
/*
Url {
protocol: 'mailto:',
slashes: null,
auth: 'abc',
host: 'example.com',
port: null,
hostname: 'example.com',
hash: null,
search: null,
query: null,
pathname: null,
path: null,
href: 'mail:abc@example.com'
}
*/
Fix created hexojs/hexo-util#102 |
9cee028 to
382b0de
Compare
What does it do?
Continuation of #3708, this PR deals with helpers and tag plugins.
How to test
Pull request tasks