Add period to URL if value is not default

This commit is contained in:
timvisee 2023-01-12 14:10:13 +01:00
parent aa719c5d67
commit d866af6b06
No known key found for this signature in database
GPG Key ID: B8DB720BC383E172
1 changed files with 5 additions and 2 deletions

View File

@ -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(),