From 6532f7681feff20f85122a50962915b103cfc69f Mon Sep 17 00:00:00 2001 From: Tom Parker-Shemilt Date: Thu, 30 Apr 2020 22:04:01 +0100 Subject: [PATCH] Only do Github API rewrite if have environment variables --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index db5a60f..cf50878 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,7 +126,7 @@ fn get_url(url: String) -> BoxFuture<'static, (String, Result<(), CheckerError>) static ref GITHUB_REPO_REGEX: Regex = Regex::new(r"^https://github.com/(?P[^/]+)/(?P[^/]+)$").unwrap(); static ref GITHUB_API_REGEX: Regex = Regex::new(r"https://api.github.com/").unwrap(); } - if GITHUB_REPO_REGEX.is_match(&url) { + if env::var("GITHUB_USERNAME").is_ok() && env::var("GITHUB_TOKEN").is_ok() && GITHUB_REPO_REGEX.is_match(&url) { let rewritten = GITHUB_REPO_REGEX.replace_all(&url, "https://api.github.com/repos/$org/$repo"); info!("Replacing {} with {} to workaround rate limits on Github", url, rewritten); let (_new_url, res) = get_url(rewritten.to_string()).await;