Skip to content

Commit

Permalink
fix(warg): Set non-https URLs properly
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Thomas <taylor@cosmonic.com>
  • Loading branch information
thomastaylor312 committed Jul 16, 2024
1 parent 5376a27 commit 637284b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/wasm-pkg-client/src/warg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,23 @@ impl WargBackend {
let warg_meta = registry_meta
.protocol_config::<WargRegistryMetadata>("warg")?
.unwrap_or_default();
let url = warg_meta.url.unwrap_or_else(|| registry.to_string());

let WargRegistryConfig {
client_config,
auth_token,
..
} = registry_config.try_into()?;

let url = warg_meta.url.unwrap_or_else(|| {
// If we just pass registry plain, warg will assume it is https. This is a workaround to
// assume that a local registry is http.
if registry.host() == "localhost" || registry.host() == "127.0.0.1" {
format!("http://{registry}")
} else {
format!("https://{registry}")
}
});

let client =
FileSystemClient::new_with_config(Some(url.as_str()), &client_config, auth_token)
.await
Expand Down

0 comments on commit 637284b

Please sign in to comment.