From 4a245d25047722431a35478e8e53c62c03e69f59 Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Sat, 23 May 2020 14:30:41 +0000 Subject: [PATCH] Check supplied base url has leading slash and append tailing slash if needed --- src/config.cr | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/config.cr b/src/config.cr index 4753850..e1a6cae 100644 --- a/src/config.cr +++ b/src/config.cr @@ -42,6 +42,7 @@ class Config cfg_path = File.expand_path path, home: true if File.exists? cfg_path config = self.from_yaml File.read cfg_path + config.preprocess config.fill_defaults return config end @@ -71,4 +72,13 @@ class Config end {% end %} end + + def preprocess + unless base_url.starts_with? "/" + raise "base url (#{base_url}) should start with `/`" + end + unless base_url.ends_with? "/" + @base_url += "/" + end + end end