Leave IDN intact in permalink#116
Conversation
|
Maybe we should implement two |
|
I'm not sure there is a usage where IDN needs to be punycode encoded. |
lib/encode_url.js
Outdated
| parsed.search = encodeURI(safeDecodeURI(parsed.search)); | ||
| return parsed.toString(); | ||
| // preserve host (international domain name) as is. | ||
| return format(parsed, { unicode: true}); |
There was a problem hiding this comment.
url.format() doesn't support port number in Node 8, see #114. This explains the failed test in Node 8.
There was a problem hiding this comment.
A workaround is to use punycode api
const { toUnicode } = require('./punycode');
return parsed.toString().replace(parsed.hostname, toUnicode(parsed.hostname));There was a problem hiding this comment.
readme also needs to be updated.
There was a problem hiding this comment.
node 8 EOL is arround the corner, and will probably imply that this package, as well as many other and also hexo have a major version bump.
So this PR can wait a bit for another PR to drop node 8 compatibility
There was a problem hiding this comment.
we can use the workaround temporarily until node 8 EOL. I don't think this is a breaking change, I do agree IDN users would prefer not to punycode.
If this PR wait for hexo's major version bump, it would be many months away.
There was a problem hiding this comment.
Added the workaround. another change introduced by this PR is that IDN whether it's in unicode or punycoded is always encoded to unicode.
encodeURL(http://xn--br-mia.com/baz')
// http://bár.com/baz
When permalink is encoded by default, it breaks If a plugin wants to remain compatible with <v4, they can use If the IDN is not punycoded, But of course, as we learned from hexo-generator-feed & hexo-generator-sitemap, Note that I still +1 this PR. |
Because IDN only contain unicode, they do not need to be punycode encoded. (I bought one, I want the nice version, not the ugly one) See https://nodejs.org/docs/latest/api/url.html#url_url_format_url_options
Because IDN only contain unicode, they do not need to be punycode encoded.
(I bought one, I want the nice version, not the ugly one)
See https://nodejs.org/docs/latest/api/url.html#url_url_format_url_options