Skip to content

Ignore empty parsed_url.scheme and netloc in get_active #169

Open
@HiPhish

Description

@HiPhish

In my code I often have site URLs like foo/bar/baz/ instead of https://example.com/foo/bar/baz because they work equally well regardless of where the site is running. However, the logic in NavItem.get_active does compare the scheme and netloc of the request and the URL of the navigation item. If the latter is empty the condition will fail because the request does carry that information.

        if (
            parsed_url.scheme != parsed_request.scheme
            or parsed_url.netloc != parsed_request.netloc
        ):
            return False

I propose adjusting the condition skip the equality check if the URL lacks that information:

        if (
            parsed_url.scheme and parsed_url.scheme != parsed_request.scheme
            or parsed_url.netloc and parsed_url.netloc != parsed_request.netloc
        ):
            return False

What is your opinion?

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