Skip to content

Commit

Permalink
Merge pull request #27 from dfinity/igornovg/fix-redirect
Browse files Browse the repository at this point in the history
fix redirect
  • Loading branch information
r-birkner authored Aug 23, 2024
2 parents 13cb470 + 949034b commit 94459d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/routing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ impl RequestCtx {
pub async fn redirect_to_https(
Host(host): Host,
OriginalUri(uri): OriginalUri,
) -> impl IntoResponse {
) -> Result<impl IntoResponse, ErrorCause> {
let fallback_path = PathAndQuery::from_static("/");
let pq = uri.path_and_query().unwrap_or(&fallback_path).as_str();

Redirect::permanent(
Ok(Redirect::permanent(
&Uri::builder()
.scheme("https")
.authority(host)
.path_and_query(pq)
.build()
.unwrap()
.map_err(|_| ErrorCause::MalformedRequest("incorrect url".into()))?
.to_string(),
)
))
}

#[allow(clippy::too_many_arguments)]
Expand Down

0 comments on commit 94459d1

Please sign in to comment.