Skip to content

PATH_EMPTY regex does not actually match empty path #88

Closed
@milo-minderbinder

Description

@milo-minderbinder

PATH_EMPTY = "^$"

The PATH_EMPTY regex won't ever match anything when embedded within another regex, as it is in several places like here:

HIER_PART_RE = "(//{}{}|{}|{}|{})".format(
COMPONENT_PATTERN_DICT["authority"],
PATH_ABEMPTY,
PATH_ABSOLUTE,
PATH_ROOTLESS,
PATH_EMPTY,
)

This causes the URIReference.is_absolute() method to return an incorrect result for a URI with a scheme but no path. For example, http: (or even http:?q=v) is an absolute URI according to section-4.3, but URIReference.from_string('http:').is_absolute() returns False.

There are likely other places where this causes intended matches to fail, but I have not tried to investigate further. It's a little odd looking, but a fix that would probably work is just to change the value of PATH_EMPTY to an empty string.

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