-
-
Notifications
You must be signed in to change notification settings - Fork 126
-
Hey folks
I was going through your docs here: https://ada-url.readthedocs.io/en/latest/ and couldn't help but think it would be cool if the URL class had support for Path-like "notation" (from pathlib import Path)
For example, instead of having to do this:
from ada_url import join_url base_url = 'http://a/b/c/d;p?q' join_url(base_url, '../g')
This could be handled simply by the base class:
from ada_url import URL base_url = URL("http://example.com") about_url = base_url / "about"
The output of about_url should be: http://example.com/about, the class itself handles the compliance based consistencies & things like stripping / joining of "/" strings etc
Just like pathlibs Path obejects.
This could probably also be extended by allowing queries, searches and other api-like url structures to be handled by other operators "&" and "|" for eg
This also get's people used to the idea of working with a URL object, which is typically more helpful when encouraging people to conform to some kind of compliance as it lends itself better to more pythonic code & easier typing
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
Sounds like a good idea. We can support both of them.
Beta Was this translation helpful? Give feedback.
All reactions
-
Here is a branch to test out.
Beta Was this translation helpful? Give feedback.