Check redirect locations are valid Uris (#486)

Closes #484
This commit is contained in:
Sean McArthur
2019-04-01 11:13:01 -07:00
committed by GitHub
parent d62f8c2bbd
commit 5c3494b81d
4 changed files with 52 additions and 8 deletions

View File

@@ -38,10 +38,14 @@ impl<'a> PolyfillTryInto for &'a String {
}
}
pub(crate) fn to_uri(url: &Url) -> ::hyper::Uri {
pub(crate) fn expect_uri(url: &Url) -> ::hyper::Uri {
url.as_str().parse().expect("a parsed Url should always be a valid Uri")
}
pub(crate) fn try_uri(url: &Url) -> Option<::hyper::Uri> {
url.as_str().parse().ok()
}
#[cfg(test)]
mod tests {
use super::*;