Strip trailing slash from the blog URL

This commit is contained in:
G-J van Rooyen 2024-04-28 19:20:02 +02:00
parent 131da978f9
commit dabd156c42

View file

@ -2,6 +2,7 @@
//// blog quickly.
import gleam/uri
import gleam/string
import scriptorium/compiler
import scriptorium/config.{type Configuration, Compiling, Configuration, Rendering}
import scriptorium/parser
@ -34,6 +35,14 @@ pub fn default_config(
author: config.Author,
copyright: String,
) -> Configuration {
// Drop any trailing slash from the blog URL, otherwise a `blog_url` like
// "https://my.blog.example/" will end up having a root path of "/" instead
// of "".
let blog_url = case string.ends_with(blog_url, "/") {
True -> string.drop_right(blog_url, 1)
False -> blog_url
}
let assert Ok(parsed_url) = uri.parse(blog_url)
Configuration(