From b09b51c74bd4a26bb1ba4c2cb40a9643c558321d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Mon, 27 May 2019 13:34:38 +0200 Subject: [PATCH] normalize URLs before setting them --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index ec138744..8bf93b2b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,7 +50,7 @@ use plume_models::{ search::{Searcher as UnmanagedSearcher, SearcherError}, Connection, Error, CONFIG, }; -use rocket::{fairing::AdHoc, http::uri::Origin}; +use rocket::{fairing::AdHoc, http::ext::IntoOwned, http::uri::Origin}; use rocket_csrf::CsrfFairingBuilder; use scheduled_thread_pool::ScheduledThreadPool; use std::process::exit; @@ -183,7 +183,9 @@ Then try to restart Plume let host = req.guard::(); if host.is_success() { let rewrite_uri = format!("/custom_domains/{}/{}", host.unwrap(), req.uri()); - req.set_uri(Origin::parse_owned(rewrite_uri).unwrap()) + let uri = Origin::parse_owned(rewrite_uri).unwrap(); + let uri = uri.to_normalized().into_owned(); + req.set_uri(uri); } });