yarl
yarl copied to clipboard
Support using the subtraction operator to get the relative path between URLs
What do these changes do?
Support for using the subtraction operator to calculate the difference between the paths of two URLs. A new URL with the relative path is returned to the user.
Usage:
from yarl import URL
target = URL("http://example.com/path/index.html")
base = URL("http://example.com/path/")
rel = target - base
print(rel) # output: "index.html"
Are there changes in behavior for the user?
Now the user can easily calculate the relative path between two URLs!
Related issue number
Resolves #1183
Checklist
- [x] I think the code is well written
- [x] Unit tests for the changes exist
- [x] Documentation reflects the changes