We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 123882b commit f3f3757Copy full SHA for f3f3757
src/models/uri.rs
@@ -7,7 +7,14 @@ pub struct Uri(Url);
7
8
impl Uri {
9
pub fn new(uri: &str) -> Self {
10
- Self(Url::parse(uri).expect("should be a valid url"))
+ let uri = if uri.starts_with("https://") || uri.starts_with("http://") {
11
+ uri
12
+ } else {
13
+ &format!("https://{uri}")
14
+ };
15
+
16
+ let message = format!("should be a valid url: {uri}");
17
+ Self(Url::parse(uri).unwrap_or_else(|_| panic!("{}", message)))
18
}
19
20
0 commit comments