From ee2156a2cac54693abece54c8e3f2f5e5d7ef344 Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Sat, 4 Apr 2020 01:40:49 +0800 Subject: [PATCH] update remove_endpoint_http_or_s --- src/oss_util.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/oss_util.rs b/src/oss_util.rs index 20eaa75..f825a65 100644 --- a/src/oss_util.rs +++ b/src/oss_util.rs @@ -103,10 +103,10 @@ impl OSSClient { // https://endpoint, or http://endpoint -> endpoint fn remove_endpoint_http_or_s(endpoint: &str) -> String { let mut endpoint = endpoint.to_owned(); - if endpoint.starts_with("http://") { - endpoint = endpoint.chars().skip("http://".chars().count()).collect::(); - } else if endpoint.starts_with("https://") { - endpoint = endpoint.chars().skip("https://".chars().count()).collect::(); + for prefix in vec!["http://", "https://"] { + if endpoint.starts_with(prefix) { + endpoint = endpoint.chars().skip(prefix.chars().count()).collect::() + } } endpoint }