Skip to content

Same URL in Unicode isn't equal to the same ASCII URL #94

Open
@jage

Description

@jage

This is the case since we compare with to_s (code).

[15] pry(main)> u1 = Twingly::URL.parse("https://www.foo.ایران.ir/bar")
=> #<Twingly::URL:0x3fc621e4ca10 https://www.foo.ایران.ir/bar>
[16] pry(main)> u2 = Twingly::URL.parse("https://www.foo.xn--mgba3a4f16a.ir/bar")
=> #<Twingly::URL:0x3fc621e00f34 https://www.foo.xn--mgba3a4f16a.ir/bar>
[17] pry(main)>
[18] pry(main)> u1 <=> u2
=> 1
[19] pry(main)> u1.to_s
=> "https://www.foo.ایران.ir/bar"
[20] pry(main)> u2.to_s
=> "https://www.foo.xn--mgba3a4f16a.ir/bar"
[21] pry(main)>

We might also consider using the normalized version when comparing (might not be what we want though).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions