Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/cli/test_ls_cache
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi
if [[ $output == *"GET https://mise-versions.jdx.dev/api/github/repos/sharkdp/bat/releases/latest"* ]]; then
fail "[mise -v ls bat] unexpectedly fetched the GitHub latest release from mise-versions"
fi
if [[ $output == *"GET https://mise-versions.jdx.dev/tools/bat.toml"* ]]; then
if [[ $output == *"GET https://mise-versions.jdx.dev/data/bat.toml"* ]]; then
fail "[mise -v ls bat] unexpectedly fetched the versions host"
fi
ok "[mise -v ls bat] reused cached metadata"
16 changes: 14 additions & 2 deletions src/versions_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ pub async fn list_versions(tool: &str) -> eyre::Result<Option<Vec<VersionInfo>>>
return Ok(None);
}

// Use TOML format which includes created_at timestamps
let url = format!("https://mise-versions.jdx.dev/tools/{}.toml", tool);
// Use the static TOML asset which includes created_at timestamps.
let url = version_list_url(tool);
let versions: Vec<VersionInfo> = match HTTP_FETCH
.get_text_request(&url)
.headers(&VERSIONS_HOST_HEADERS)
Expand Down Expand Up @@ -612,6 +612,10 @@ fn track_install_url(tool: &str) -> String {
)
}

fn version_list_url(tool: &str) -> String {
format!("https://mise-versions.jdx.dev/data/{}.toml", tool)
}

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -632,6 +636,14 @@ mod tests {
);
}

#[test]
fn test_version_list_url_uses_static_asset_path() {
assert_eq!(
version_list_url("node"),
"https://mise-versions.jdx.dev/data/node.toml"
);
}

#[test]
fn test_versions_host_log_context_fields_quotes_spaces() {
let fields =
Expand Down
Loading