Show fully-resolved URLs in non-resolution contexts (#689)

We now show the fully-resolved URL, rather than the URL as given by the
user, _everywhere_ except for the output resolution file (which should
retain relative paths, unexpanded environment variables, etc.).

Closes https://github.com/astral-sh/puffin/issues/687.
This commit is contained in:
Charlie Marsh 2023-12-18 17:10:24 -05:00 committed by GitHub
parent 43c837f7bb
commit 365c860e27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 123 additions and 39 deletions

View file

@ -37,6 +37,11 @@ impl VerbatimUrl {
})
}
/// Return the original string as given by the user, if available.
pub fn given(&self) -> Option<&str> {
self.given.as_deref()
}
/// Return the underlying [`Url`].
pub fn raw(&self) -> &Url {
&self.url
@ -66,11 +71,7 @@ impl std::str::FromStr for VerbatimUrl {
impl std::fmt::Display for VerbatimUrl {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Some(given) = &self.given {
given.fmt(f)
} else {
self.url.fmt(f)
}
self.url.fmt(f)
}
}