From d866af6b066d9e6840d5b4119a579c50ac812883 Mon Sep 17 00:00:00 2001 From: timvisee Date: Thu, 12 Jan 2023 14:10:13 +0100 Subject: [PATCH] Add period to URL if value is not default --- src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4c2812b..6702570 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -634,6 +634,9 @@ impl TOTP { } else { account_name }; + if self.step != 30 { + params.push(format!("period={}", self.step)); + } format!("otpauth://{}/{}?{}", host, label, params.join("&")) } @@ -1173,7 +1176,7 @@ mod tests { Algorithm::SHA1, 6, 1, - 1, + 30, "TestSecretSuperSecret".as_bytes().to_vec(), Some("Github".to_string()), "constantoine".to_string(), @@ -1192,7 +1195,7 @@ mod tests { Algorithm::SHA1, 6, 1, - 1, + 30, "TestSecretSuperSecret".as_bytes().to_vec(), Some("Github".to_string()), "constantoine".to_string(),