Merge branch 'trunk' into 'trunk'

Strip trailing slash from the blog URL

See merge request Nicd/scriptorium!1
This commit is contained in:
Mikko Ahlroth 2024-04-28 17:47:02 +00:00
commit 32cba3db6e

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(