Skip to content

repr() of a relative URL does not round-trip: eval(repr(u)) != u #210

Open

Description

@ines-besrour

For a URL without a scheme, reading back its printed form gives an unequal URL:

>>> from hyperlink import URL
>>> u = URL.from_text("a b")
>>> u
URL.from_text('a%20b')
>>> URL.from_text("a%20b") == u
False

With a scheme it works: URL.from_text("http://example.com/a b") prints back unchanged and compares equal.

Cause: in _encode_path_parts, the first segment of a scheme-less path is encoded without passing maximal, so to_text() encodes it fully.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions