Skip to content
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

Feature: Addition of is_domain flag #151

Open
znd4 opened this issue Dec 3, 2021 · 0 comments
Open

Feature: Addition of is_domain flag #151

znd4 opened this issue Dec 3, 2021 · 0 comments

Comments

@znd4
Copy link

znd4 commented Dec 3, 2021

This idea has been floated in a couple of comments (thanks @pramttl and @fearless0307 !). I just thought it'd be worth creating a standalone issue for this idea and maybe fleshing it out a bit.

I'm currently thinking of behavior like:

f_bare = furl("github.com", is_domain=True, scheme="https")
f_http = furl("http://github.com", is_domain=True, scheme="https")
f_https = furl("https://github.com", is_domain=True, scheme="https")

{f_bare.url, f_http.url, f_https.url} = {"https://github.com"}  # True

The motivation that I see for this is I'd like to be able to cleanly implement a function to coerce a domain to include the https schema. I can currently do that like this, but it's a bit hacky:

def coerce_to_https(url: str) -> str:
    url = url.removeprefix("http://").removeprefix("https://")
    return furl(host=url, scheme="https").url

assert {
    coerce_to_https("github.com"),
    coerce_to_https("http://github.com"),
    coerce_to_https("https://github.com"),
} == {"https://github.com"}

Thanks, I love this library btw <3

@znd4 znd4 changed the title Addition of is_domain flag Feature: Addition of is_domain flag Dec 3, 2021
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

No branches or pull requests

1 participant