-
-
Notifications
You must be signed in to change notification settings - Fork 12
Implement TryFrom<GitUrl> for url::Url #66
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
Conversation
GitUrl::url_compat_display() is currently private, but it would be very useful to have this functionality - in my case, normalizing an SSH style URL is fine, especially because I do not want to bother with handling the 'url lifetime of GitUrl in my wrapper enum. This change implements fallible conversion to url::Url for GitUrl and &GitUrl via url_compat_display(). Longer term it might be wise to re-visit the use of a lifetime for the purpose of re-using slices of the input string - the url::Url crate does not bother with such micro-optimizations either, presumably for good reasons. Obviously, to use a GitUrl as a url::Url, the conversion to url::Url still has to happen twice (because GitUrl::parse() incurs the conversion via GitUrl::is_valid()), but that can be optimized in a separate change (e.g. via a new GitUrl::parse_to_url(), or by removing the conversion from is_valid() altogether, leaving it to the caller to attempt the conversion).
Ideally, I'd like to enhance the overall quality of the parsing to the point where I can remove In the meantime, converting to
I appreciate this feedback. This is fair, and worth a review in the future. Thanks for your time and the contribution! |
## 🤖 New release * `git-url-parse`: 0.5.1 -> 0.5.2 (✓ API compatible changes) <details><summary><i><b>Changelog</b></i></summary><p> <blockquote> ## [0.5.2](v0.5.1...v0.5.2) - 2025-09-16 ### Added - Implement TryFrom<GitUrl> for url::Url ([#66](#66)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Version 0.5.2 includes tjtelan/git-url-parse-rs#66 which we need. Pinning to 0.5.x for now since there might be other breaking/structural changes coming soon. GUS-W-19637481
Thank you for the super quick merge and release, very much appreciated! |
Version 0.5.2 includes tjtelan/git-url-parse-rs#66 which we need. Pinning to 0.5.x for now since there might be other breaking/structural changes coming soon. GUS-W-19637481
Version 0.5.2 includes tjtelan/git-url-parse-rs#66 which we need. Pinning to 0.5.x for now since there might be other breaking/structural changes coming soon. GUS-W-19637481
GitUrl::url_compat_display()
is currently private, but it would be very useful to have this functionality - in my case, normalizing an SSH style URL is fine, especially because I do not want to bother with handling the'url
lifetime ofGitUrl
in my wrapper enum.This change implements fallible conversion to
url::Url
forGitUrl
and&GitUrl
viaGitUrl::url_compat_display()
.Longer term it might be wise to re-visit the use of a lifetime for the purpose of re-using slices of the input string - the
url::Url
crate does not bother with such micro-optimizations either, presumably for good reasons.Obviously, to use a
GitUrl
as aurl::Url
, the conversion tourl::Url
still has to happen twice (becauseGitUrl::parse()
incurs the conversion viaGitUrl::is_valid()
), but that can be optimized in a separate change, e.g. via a newGitUrl::parse_to_url()
, or by removing the conversion fromGitUrl::is_valid()
altogether, leaving it to the caller to attempt the conversion.