diff --git a/src/database/entry.rs b/src/database/entry.rs index 47fa1d7..57a61c5 100644 --- a/src/database/entry.rs +++ b/src/database/entry.rs @@ -184,7 +184,7 @@ impl EntryValue { Ok(num) => EntryValue::Number(num), Err(_) => { lazy_static! { - static ref URL_REGEX: Regex = Regex::new("^[a-zA-Z0-9_]://").unwrap(); + static ref URL_REGEX: Regex = Regex::new("^[a-zA-Z0-9_]+://").unwrap(); } if URL_REGEX.is_match(string) { EntryValue::Address(Address::Url(string.to_string())) @@ -309,4 +309,20 @@ mod tests { let addr = Address::Url("https://upend.dev".into()); assert_eq!(EntryValue::Address(addr.clone()), addr.into()); } + + #[test] + fn test_guess_value() { + assert_eq!( + EntryValue::guess_from("UPEND"), + EntryValue::String("UPEND".into()) + ); + assert_eq!( + EntryValue::guess_from("1337.93"), + EntryValue::Number(1337.93) + ); + assert_eq!( + EntryValue::guess_from("https://upend.dev"), + EntryValue::Address(Address::Url("https://upend.dev".to_string())) + ); + } }