-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Preserve original trailing slash if present in find-links
URLs
#14387
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
base: main
Are you sure you want to change the base?
Conversation
f527ad5
to
caa4b8d
Compare
caa4b8d
to
5233821
Compare
I think relying on |
find-links
requestfind-links
URLs
41143c0
to
2cc4ce5
Compare
cdbc20f
to
a5ac13d
Compare
|
||
/// Construct an [`IndexUrl`] from a [`VerbatimUrl`], applying a [`TrailingSlashPolicy`] | ||
/// to non-file URLs. | ||
fn from_verbatim_url_with_trailing_slash_policy( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic was moved from the From<VerbatimUrl>
implementation. It's unchanged except that the trailing slash is only removed if TrailingSlashPolicy::Remove
is passed in.
Updated. I've also updated the |
find-links
URLsfind-links
URLs
a5ac13d
to
6012b9d
Compare
/// directory. | ||
/// | ||
/// Preserves trailing slash if present in `path`. | ||
pub fn parse_preserving_trailing_slash(path: &str) -> Result<Self, IndexUrlError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like this name. Originally I had it as parse_without_slash_normalization
. Could be parse_preserve_trailing_slash
but I think parse_preserve_slash
isn't enough information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I avoided things like parse_as_given
or parse_exact
since there could have already been different kinds of normalization prior to this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we just use:
parse_simple_api
parse_find_links
And thus not require callers to pass in a trailing slash policy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's better. I can follow a similar pattern with the verbatim URL cases: e.g., simple_api_from_verbatim_url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah or from_simple_api_url
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
|
||
/// Construct an [`IndexUrl`] from a [`VerbatimUrl`], preserving a trailing | ||
/// slash if present. | ||
pub fn from_verbatim_url_preserving_trailing_slash(url: VerbatimUrl) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same point as above about the function name
…erialization (#14456) This came up in [discussion](#14387 (comment)) on #14387.
fn from(url: VerbatimUrl) -> Self { | ||
// Remove trailing slashes for consistency. They'll be re-added if necessary when | ||
// querying the Simple API. | ||
Self::from_verbatim_url_with_trailing_slash_policy(url, TrailingSlashPolicy::Remove) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just get rid of this, since it seems like callers must be cognizant of whether they want to preserve or remove the trailing slash.
87b2cd6
to
081168d
Compare
081168d
to
29651ed
Compare
Actually, hmm, there may be one bug here. We call |
We should probably try to find a way to remove |
As part of #14245 and #14346, uv was normalizing trailing slashes for find-links URLs by removing them. However, find-links URLs have different meanings depending on whether a trailing slash is present (as evidenced in 301 redirects from PyPI and #14367). This PR preserves trailing slashes if present in find-links URLs.
Fixes #14367