From def7516b423e5d5b5520e38131242bec60251403 Mon Sep 17 00:00:00 2001 From: James Williams Date: Fri, 3 May 2024 11:09:37 -0700 Subject: [PATCH] Restore trailing slash behaviour in serve command (#2482) * Restore trailing slash behaviour in serve command. * Restore guard in case where base_url is just a slash. --- src/cmd/serve.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/serve.rs b/src/cmd/serve.rs index 27c9b057bb..d3aa01f660 100644 --- a/src/cmd/serve.rs +++ b/src/cmd/serve.rs @@ -396,7 +396,11 @@ fn create_new_site( |u| u.to_string(), ); - let constructed_base_url = construct_url(&base_url, no_port_append, interface_port); + let mut constructed_base_url = construct_url(&base_url, no_port_append, interface_port); + + if !site.config.base_url.ends_with("/") && constructed_base_url != "/" { + constructed_base_url.truncate(constructed_base_url.len() - 1); + } site.enable_serve_mode(); site.set_base_url(constructed_base_url.clone());