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

Expand environment variables prior to detecting scheme #2394

Merged
merged 2 commits into from
Mar 12, 2024

Conversation

charliermarsh
Copy link
Member

Summary

This PR ensures that we expand environment variables before sniffing for the URL scheme (e.g., file:// vs. https:// vs. something else).

Closes #2375.

@charliermarsh charliermarsh added the bug Something isn't working label Mar 12, 2024
@@ -198,21 +181,12 @@ fn expand_env_vars(s: &str, escape: Escape) -> Cow<'_, str> {
RE.replace_all(s, |caps: &regex::Captures<'_>| {
let name = caps.name("name").unwrap().as_str();
std::env::var(name).unwrap_or_else(|_| match name {
// Ensure that the variable is URL-escaped, if necessary.
"PROJECT_ROOT" => match escape {
Escape::Url => PROJECT_ROOT_FRAGMENT.replace(' ', "%20"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this isn't necessary. If the root is in a file://, we already strip that as a special case and parse this as a path, so spaces are fine.

@charliermarsh charliermarsh force-pushed the charlie/expand branch 2 times, most recently from eb63ed6 to 0b4fa81 Compare March 12, 2024 21:00
@charliermarsh charliermarsh force-pushed the charlie/expand branch 4 times, most recently from a8cf59d to ffc16bd Compare March 12, 2024 21:07
@charliermarsh charliermarsh marked this pull request as ready for review March 12, 2024 23:17
@charliermarsh charliermarsh merged commit 7220894 into main Mar 12, 2024
26 checks passed
@charliermarsh charliermarsh deleted the charlie/expand branch March 12, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

URL Environment Variable Substitution ordering
2 participants