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

Add with_suffix() method #613

Closed
1 task done
michaelaye opened this issue Aug 27, 2021 · 1 comment · Fixed by #670
Closed
1 task done

Add with_suffix() method #613

michaelaye opened this issue Aug 27, 2021 · 1 comment · Fixed by #670

Comments

@michaelaye
Copy link

Is your feature request related to a problem?

I love how yarl follows the pathlib.Path syntax, so was a bit disappointed to not have a with_suffix() method when I needed it. Could it be added?

Describe the solution you'd like

Similar to pathlib, with_suffix() should take a URL to a file, like:

url = yarl.URL("https://a.b.com/index.html")

and change it to:

url.with_suffix(".md")

-> https://a.b.com/index.md

Describe alternatives you've considered

with_name() works as a workaround, but it's sometimes cumbersome to fish out the name first, and do string ops on it before adding it back to the URL.

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@asvetlov
Copy link
Member

asvetlov commented Oct 5, 2021

The request makes sense.
Please feel free to prepare a patch.
I would say that .suffix attribute should be supported if .with_suffix() is added.

@q0w q0w mentioned this issue Jan 21, 2022
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants