Check supplied base url has leading slash and append tailing slash if needed

This commit is contained in:
Alex Ling 2020-05-23 14:30:41 +00:00
parent 48c3a82078
commit 4a245d2504

View File

@ -42,6 +42,7 @@ class Config
cfg_path = File.expand_path path, home: true cfg_path = File.expand_path path, home: true
if File.exists? cfg_path if File.exists? cfg_path
config = self.from_yaml File.read cfg_path config = self.from_yaml File.read cfg_path
config.preprocess
config.fill_defaults config.fill_defaults
return config return config
end end
@ -71,4 +72,13 @@ class Config
end end
{% end %} {% 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 end