Feature: Addition of `is_domain` flag
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Description
This idea has been floated in a [couple](https://github.com/gruns/furl/issues/112#issuecomment-462267721) of [comments](https://github.com/gruns/furl/issues/103#issuecomment-893146632) (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:
```python
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:
```python
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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.