Extract Location URL path correctly in client::request. (fixes #645)

This commit is contained in:
Daniel Valentine 2022-11-20 23:25:20 -07:00
parent 3a33c70e7c
commit 85e4a690f3
1 changed files with 3 additions and 3 deletions

View File

@ -158,10 +158,10 @@ fn request(method: &'static Method, path: String, redirect: bool, quarantine: bo
method,
response
.headers()
.get("Location")
.get(header::LOCATION)
.map(|val| {
let new_url = percent_encode(val.as_bytes(), CONTROLS).to_string();
format!("{}{}raw_json=1", new_url, if new_url.contains('?') { "&" } else { "?" })
let new_path = percent_encode(val.as_bytes(), CONTROLS).to_string().trim_start_matches(REDDIT_URL_BASE).to_string();
format!("{}{}raw_json=1", new_path, if new_path.contains('?') { "&" } else { "?" })
})
.unwrap_or_default()
.to_string(),