Commit 3f7f91299fe7dd92a5531b6545070b1e8b3d3dfa

timvisee 2023-01-03T18:36:35

Generate proper URLs for Steam algorithm

diff --git a/src/lib.rs b/src/lib.rs
index d7c256a..fe368f4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -598,6 +598,12 @@ impl TOTP {
     /// Secret will be base 32'd without padding, as per RFC.
     #[cfg(feature = "otpauth")]
     pub fn get_url(&self) -> String {
+        #[allow(unused_mut)]
+        let mut host = "totp";
+        #[cfg(feature = "steam")]
+        if self.algorithm == Algorithm::Steam {
+            host = "steam";
+        }
         let account_name: String = urlencoding::encode(self.account_name.as_str()).to_string();
         let mut label: String = format!("{}?", account_name);
         if self.issuer.is_some() {
@@ -607,7 +613,8 @@ impl TOTP {
         }
 
         format!(
-            "otpauth://totp/{}secret={}&digits={}&algorithm={}",
+            "otpauth://{}/{}secret={}&digits={}&algorithm={}",
+            host,
             label,
             self.get_secret_base32(),
             self.digits,