Skip to content

Conversation

@curbengh
Copy link
Contributor

@curbengh curbengh requested a review from tomap August 10, 2019 06:10
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling d84c404 on curbengh:idn into ef8a8cf on hexojs:master.

@tomap
Copy link
Contributor

tomap commented Aug 11, 2019

I will test it on a sample site and merge :)

@tomap
Copy link
Contributor

tomap commented Aug 11, 2019

I tested with a site without IDN, but in that case, https://hexo-theme-minidyne-demo.netlify.com/sitemap.xml
it seems to work

@curbengh
Copy link
Contributor Author

curbengh commented Aug 12, 2019

You can test locally and change the url.
My local test yields sitemap.xml


I just noticed this PR doesn't uriencode root value, even though it should. I'll update.
hexo-generator-feed may need to be updated as well.


URL api can be used to parse the url to separate each component. Legacy api is needed for node 8 compatibility. It doesn't encode uri however.

const url = require('url')
const string = 'https://日本語テストgôg.com/hexô-testing'

console.log(url.parse(string).href)
// https://xn--gg-8ja8200c3ban0926g0ecl32k.com/hexô-testing

console.log(url.format({
  protocol: url.parse(string).protocol,
  hostname: url.parse(string).hostname,
  pathname: encodeURIComponent(url.parse(string).pathname),
}))

// https://xn--gg-8ja8200c3ban0926g0ecl32k.com/hex%C3%B4-testing

URL api always output hostname in punycode though. is punycode okay?

@curbengh
Copy link
Contributor Author

Superseded by #66

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants