Skip to content

Commit

Permalink
Strip .py suffix from file_stem
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Sep 26, 2024
1 parent 284b919 commit b15f948
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ async fn resolve_script_target(
}

let script_url = url::Url::parse(&maybe_url)?;
let file_name = script_url
let file_stem = script_url
.path_segments()
.and_then(std::iter::Iterator::last)
.unwrap_or("script.py");
.and_then(|segment| segment.strip_suffix(".py"))
.unwrap_or("script");

let temp_file = tempfile::Builder::new()
.prefix(file_name)
.prefix(file_stem)
.suffix(".py")
.tempfile()?;
let response = reqwest::get(script_url).await?;
Expand Down

0 comments on commit b15f948

Please sign in to comment.