Skip to content
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

Punycode support #552

Open
shirenn opened this issue Feb 15, 2022 · 4 comments
Open

Punycode support #552

shirenn opened this issue Feb 15, 2022 · 4 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@shirenn
Copy link

shirenn commented Feb 15, 2022

RFC5891 provides a way to use internationalized domain names. Currently they are not rendered properly in nitter (see there for an example)

@shirenn shirenn changed the title Punnycode support Punycode support Feb 15, 2022
@shirenn
Copy link
Author

shirenn commented Feb 15, 2022

import std/strutils
from std/sugar import collect
from std/punycode import decode
import std/uri

echo "URI to sanitize : "
var name: string = readline(stdin)
var url: Uri = parseUri(name)
var bits: seq[string] = url.hostname.split(".")
let cleaned_bits: seq[string] = sugar.collect(newSeq):
    for bit in bits:
        if bit.startsWith("xn--"):
            decode(bit[4 .. ^1])
        else:
            bit
var cleaned_hostname: string = cleaned_bits.join(".")
var cleaned_url: Uri = url
cleaned_url.hostname = cleaned_hostname
echo $cleaned_url

This snippet transforms punycode encoded uris to their utf8 representation. Though, I don't think it is really idiomatic and I wouldn't know how to insert it in nitter source.

@zedeus zedeus added bug Something isn't working enhancement New feature or request labels Feb 24, 2022
@makipony
Copy link

I'm looking into maybe sending a pr with punycode support, but it seems that nim's std/punycode is broken. Even outside their playground I can't figure much out. I'll keep looking for solutions and come back later

@zedeus
Copy link
Owner

zedeus commented May 19, 2022

This is fixed in Nim devel, no idea when it'll make it into an actual release though.
image

@derspyy
Copy link

derspyy commented Oct 25, 2022

Thought I'd leave a bump since it seems to be fixed on Nim :)

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants