Fix clippy warnings
This commit is contained in:
parent
b0f985c687
commit
c5d11f220e
@ -49,14 +49,14 @@ pub async fn canonical_path(path: String) -> Result<Option<String>, String> {
|
||||
let status = res.status().as_u16();
|
||||
|
||||
match status {
|
||||
429 => return Err("Too many requests.".to_string()),
|
||||
429 => Err("Too many requests.".to_string()),
|
||||
|
||||
// If Reddit responds with a 2xx, then the path is already canonical.
|
||||
200..=299 => return Ok(Some(path)),
|
||||
200..=299 => Ok(Some(path)),
|
||||
|
||||
// If Reddit responds with anything other than 3xx (except for the 2xx as
|
||||
// above), return a None.
|
||||
300..=399 => return Ok(None),
|
||||
300..=399 => Ok(None),
|
||||
|
||||
_ => Ok(
|
||||
res
|
||||
|
@ -21,7 +21,7 @@ pub(crate) static INSTANCE_INFO: Lazy<InstanceInfo> = Lazy::new(InstanceInfo::ne
|
||||
pub async fn instance_info(req: Request<Body>) -> Result<Response<Body>, String> {
|
||||
// This will retrieve the extension given, or create a new string - which will
|
||||
// simply become the last option, an HTML page.
|
||||
let extension = req.param("extension").unwrap_or(String::new());
|
||||
let extension = req.param("extension").unwrap_or_default();
|
||||
let response = match extension.as_str() {
|
||||
"yaml" | "yml" => info_yaml(),
|
||||
"txt" => info_txt(),
|
||||
|
@ -332,7 +332,6 @@ async fn main() {
|
||||
Box::pin(async move {
|
||||
let sub = req.param("sub").unwrap_or_default();
|
||||
match req.param("id").as_deref() {
|
||||
|
||||
// Share link
|
||||
Some(id) if (8..12).contains(&id.len()) => match canonical_path(format!("/r/{}/s/{}", sub, id)).await {
|
||||
Ok(Some(path)) => Ok(redirect(path.split('?').next().unwrap_or_default().to_string())),
|
||||
|
@ -353,14 +353,6 @@ fn determine_compressor(accept_encoding: String) -> Option<CompressionType> {
|
||||
|
||||
impl PartialOrd for CompressorCandidate {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
// Guard against NAN, both on our end and on the other.
|
||||
if self.q.is_nan() || other.q.is_nan() {
|
||||
return None;
|
||||
};
|
||||
|
||||
// f64 and CompressionType are ordered, except in the case
|
||||
// where the f64 is NAN (which we checked against), so we
|
||||
// can safely return a Some here.
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
36
src/utils.rs
36
src/utils.rs
@ -604,23 +604,23 @@ impl Preferences {
|
||||
}
|
||||
Self {
|
||||
available_themes: themes,
|
||||
theme: setting(&req, "theme"),
|
||||
front_page: setting(&req, "front_page"),
|
||||
layout: setting(&req, "layout"),
|
||||
wide: setting(&req, "wide"),
|
||||
show_nsfw: setting(&req, "show_nsfw"),
|
||||
blur_nsfw: setting(&req, "blur_nsfw"),
|
||||
use_hls: setting(&req, "use_hls"),
|
||||
hide_hls_notification: setting(&req, "hide_hls_notification"),
|
||||
autoplay_videos: setting(&req, "autoplay_videos"),
|
||||
fixed_navbar: setting_or_default(&req, "fixed_navbar", "on".to_string()),
|
||||
theme: setting(req, "theme"),
|
||||
front_page: setting(req, "front_page"),
|
||||
layout: setting(req, "layout"),
|
||||
wide: setting(req, "wide"),
|
||||
show_nsfw: setting(req, "show_nsfw"),
|
||||
blur_nsfw: setting(req, "blur_nsfw"),
|
||||
use_hls: setting(req, "use_hls"),
|
||||
hide_hls_notification: setting(req, "hide_hls_notification"),
|
||||
autoplay_videos: setting(req, "autoplay_videos"),
|
||||
fixed_navbar: setting_or_default(req, "fixed_navbar", "on".to_string()),
|
||||
disable_visit_reddit_confirmation: setting(req, "disable_visit_reddit_confirmation"),
|
||||
comment_sort: setting(&req, "comment_sort"),
|
||||
post_sort: setting(&req, "post_sort"),
|
||||
subscriptions: setting(&req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
|
||||
filters: setting(&req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
|
||||
hide_awards: setting(&req, "hide_awards"),
|
||||
hide_score: setting(&req, "hide_score"),
|
||||
comment_sort: setting(req, "comment_sort"),
|
||||
post_sort: setting(req, "post_sort"),
|
||||
subscriptions: setting(req, "subscriptions").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
|
||||
filters: setting(req, "filters").split('+').map(String::from).filter(|s| !s.is_empty()).collect(),
|
||||
hide_awards: setting(req, "hide_awards"),
|
||||
hide_score: setting(req, "hide_score"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1074,9 +1074,7 @@ mod tests {
|
||||
#[test]
|
||||
fn rewrite_urls_keeps_intentional_backslashes() {
|
||||
assert_eq!(
|
||||
rewrite_urls(
|
||||
"printf \"\\npolkit.addRule(function(action, subject)"
|
||||
),
|
||||
rewrite_urls("printf \"\\npolkit.addRule(function(action, subject)"),
|
||||
"printf \"\\npolkit.addRule(function(action, subject)"
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user