From 96609d25ab65fcc4ca4c5fb3e816f1d398307509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20H=C3=A5kansson?= Date: Sat, 25 May 2019 23:10:57 +0200 Subject: [PATCH] fix: Add user agent for wasm-pack version check --- src/manifest/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/manifest/mod.rs b/src/manifest/mod.rs index 205ea1092..417f6f219 100644 --- a/src/manifest/mod.rs +++ b/src/manifest/mod.rs @@ -26,6 +26,8 @@ use toml; use PBAR; const WASM_PACK_METADATA_KEY: &str = "package.metadata.wasm-pack"; +const WASM_PACK_VERSION: Option<&'static str> = option_env!("CARGO_PKG_VERSION"); +const WASM_PACK_REPO_URL: &str = "https://github.com/rustwasm/wasm-pack"; /// Store for metadata learned about a crate pub struct CrateData { @@ -224,6 +226,11 @@ impl Crate { /// Call to the crates.io api and return the latest version of `wasm-pack` fn check_wasm_pack_latest_version() -> Result { let mut easy = easy::Easy2::new(Collector(Vec::new())); + easy.useragent(&format!( + "wasm-pack/{} ({})", + WASM_PACK_VERSION.unwrap_or_else(|| "master"), + WASM_PACK_REPO_URL + ))?; easy.get(true)?; easy.url("https://crates.io/api/v1/crates/wasm-pack")?; easy.perform()?;