-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't Encode Internationalized Domain Names #1285
Comments
Looks like we would need to extract the domain name from Line 1015 in ac4f2e4
A PR would be welcome |
FYI, it looks like CommonMark has the same behavior as marked. @UziTech How would you safely extract the domain name? Maybe something like this? function getHostName() {
var url = new URL(href);
return url.hostname
} But this relies on |
Perhaps https://nodejs.org/api/url.html#url_url_format_url_options could be of help.... although use all Also https://nodejs.org/api/url.html#url_url_resolve_from_to presuming these are available... always test assertions. :) |
Why do you need to encode and then to escape: href = encodeURI(href).replace(/%25/g, '%');
var out = '<a href="' + escape(href) + '"'; What's the purpose? Can't you just do this instead: href = href.replace(/"/g, '%22')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
var out = '<a href="' + href + '"'; Or maybe just |
Also it may be not a marked fault, but a fault of |
After a little contemplation I decided I'm fine with the current behavior as long as it works in major browsers and handled by search engines. If you agree and don't see any problem with |
If I'm not mistaken there exists this at https://www.npmjs.com/package/url (haven't tried it in the DOM yet... not much time to do this at the moment). It's a bit tenured just like the node URL API. Would be nice if ECMAScript standards would incorporate some sort of improved IRI handling like this. |
@Martii There is the WHATWG URL standard which is implemented in modern browsers and newer versions of Node.js which I believe has improved IRI handling. See my comment above.
@ilyaigpetrov Thanks, I'll close this issue. |
Hi, I am using marked.js to build my own static site generator, and I found this issue, which breaks my code. I use my own implementation to convert all links to absolute path and encode them, yesterday I found marked.js do encode again so the link is wrong after encode twice. I cannot stop doing encode in my code because not all pages are generated via marked.js (tags cloud, categories...). I read this issue and have some questions:
|
@AlynxZhou marked tries to follow CommonMark spec. I think you will have to change the spec if you want this changed in marked. Otherwise you can create an extension for marked that people can use that does not encode urls. We want to stay away from adding more options to marked to prevent feature creep. |
What pain point are you perceiving?.
require('url').parse('https://%D1%81%D0%BB96.%D1%80%D1%84')
populatespathname
instead ofhostname
:Describe the solution you'd like
Please, don't percent-encode internationalized domain names, because it doesn't work well with
url.parse
. I see no reason for IDN to be encoded.The text was updated successfully, but these errors were encountered: