From eb331c531de79c16d13743debcd70c95d20dd923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luukas=20P=C3=B6rtfors?= Date: Tue, 16 Nov 2021 22:49:14 +0200 Subject: [PATCH] Fix mismatched region argument (when w=3 etc..) --- Cargo.lock | 2 +- src/vahti.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b764c0a..7fbe86e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1656,7 +1656,7 @@ dependencies = [ [[package]] name = "torimies-rs" -version = "0.1.0" +version = "0.1.1" dependencies = [ "chrono", "clokwerk", diff --git a/src/vahti.rs b/src/vahti.rs index 33bda82..d3c5ac7 100644 --- a/src/vahti.rs +++ b/src/vahti.rs @@ -74,15 +74,14 @@ fn vahti_to_api(vahti: &str) -> String { let num = url[index+2..endindex+index].parse::().unwrap(); if num >= 100 { region = num-100; + url = url.replace(&url[index..endindex+index], &format!("region={}", region)); } else if url.contains("ca=") { let nindex = url.find("ca=").unwrap(); let nendindex = url[nindex..].find('&').unwrap_or(url.len()-nindex); let num = url[nindex+3..nendindex+nindex].parse::().unwrap(); region = num; - } else { - region = num; + url = url.replace(&url[index..endindex+index], &format!("region={}", region)); } - url = url.replace(&url[index..endindex+index], &format!("region={}", region)); } else { url = url.replace("ca=", "region="); }