Skip to content

Commit def7516

Browse files
jamwilberdandy
authored andcommittedSep 17, 2024
Restore trailing slash behaviour in serve command (getzola#2482)
* Restore trailing slash behaviour in serve command. * Restore guard in case where base_url is just a slash.
1 parent fccb191 commit def7516

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/cmd/serve.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,11 @@ fn create_new_site(
396396
|u| u.to_string(),
397397
);
398398

399-
let constructed_base_url = construct_url(&base_url, no_port_append, interface_port);
399+
let mut constructed_base_url = construct_url(&base_url, no_port_append, interface_port);
400+
401+
if !site.config.base_url.ends_with("/") && constructed_base_url != "/" {
402+
constructed_base_url.truncate(constructed_base_url.len() - 1);
403+
}
400404

401405
site.enable_serve_mode();
402406
site.set_base_url(constructed_base_url.clone());

0 commit comments

Comments
 (0)