Skip to content

Commit cbcb0ee

Browse files
committed
Apply Feedback from Review
1 parent b0e460d commit cbcb0ee

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/other/referer.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ impl Referer {
6262
let url = match Url::parse(header_value.as_str()) {
6363
Ok(url) => url,
6464
Err(_) => match base_url.try_into() {
65-
Ok(base_url) => base_url.join(header_value.as_str().trim()).status(400)?,
66-
Err(_) => bail!(400, "Invalid base url provided"),
65+
Ok(base_url) => base_url.join(header_value.as_str().trim()).status(500)?,
66+
Err(_) => bail!(500, "Invalid base url provided"),
6767
},
6868
};
6969

@@ -94,14 +94,13 @@ impl Referer {
9494
}
9595

9696
/// Set the url.
97-
pub fn set_location<U>(&mut self, location: U)
97+
pub fn set_location<U>(&mut self, location: U) -> Result<(), U::Error>
9898
where
9999
U: TryInto<Url>,
100100
U::Error: std::fmt::Debug,
101101
{
102-
self.location = location
103-
.try_into()
104-
.expect("Could not convert into valid URL")
102+
self.location = location.try_into()?;
103+
Ok(())
105104
}
106105
}
107106

@@ -132,7 +131,7 @@ mod test {
132131
headers.insert(REFERER, "htt://<nori ate the tag. yum.>");
133132
let err =
134133
Referer::from_headers(Url::parse("https://example.net").unwrap(), headers).unwrap_err();
135-
assert_eq!(err.status(), 400);
134+
assert_eq!(err.status(), 500);
136135
Ok(())
137136
}
138137

src/other/source_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ impl SourceMap {
5959
let url = match Url::parse(header_value.as_str()) {
6060
Ok(url) => url,
6161
Err(_) => match base_url.try_into() {
62-
Ok(base_url) => base_url.join(header_value.as_str().trim()).status(400)?,
62+
Ok(base_url) => base_url.join(header_value.as_str().trim()).status(500)?,
6363
Err(_) => bail!(500, "Invalid base url provided"),
6464
},
6565
};
@@ -128,7 +128,7 @@ mod test {
128128
headers.insert(SOURCE_MAP, "htt://<nori ate the tag. yum.>");
129129
let err = SourceMap::from_headers(Url::parse("https://example.net").unwrap(), headers)
130130
.unwrap_err();
131-
assert_eq!(err.status(), 400);
131+
assert_eq!(err.status(), 500);
132132
Ok(())
133133
}
134134

0 commit comments

Comments
 (0)