Skip to content

Ignore empty parsed_url.scheme and netloc in get_active #169

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

Open
HiPhish opened this issue Apr 9, 2025 · 0 comments · May be fixed by #172
Open

Ignore empty parsed_url.scheme and netloc in get_active #169

HiPhish opened this issue Apr 9, 2025 · 0 comments · May be fixed by #172

Comments

@HiPhish
Copy link

HiPhish commented Apr 9, 2025

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?

HiPhish added a commit to HiPhish/django-simple-nav that referenced this issue Apr 15, 2025
Closes westerveltco#169.  If the URL of a navigation item is missing the scheme or
the network location we ignore it in the check.
HiPhish added a commit to HiPhish/django-simple-nav that referenced this issue Apr 15, 2025
Closes westerveltco#169.  If the URL of a navigation item is missing the scheme or
the network location we ignore it in the check.
@HiPhish HiPhish linked a pull request Apr 15, 2025 that will close this issue
HiPhish added a commit to HiPhish/django-simple-nav that referenced this issue Apr 16, 2025
Closes westerveltco#169.  If the URL of a navigation item is missing the scheme or
the network location we ignore it in the check.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant