feat: check domain configuration before starting Invidious (#5352)

* check domain configuration before starting Invidious

* Update src/invidious/config.cr

Co-authored-by: Samantaz Fox <coding@samantaz.fr>

* better domain missconfiguration checking

* improve

* rescue

---------

Co-authored-by: Samantaz Fox <coding@samantaz.fr>
This commit is contained in:
Fijxu
2026-11-03 00:41:53 -03:00
committed by GitHub
parent 7830246777
commit 8cabd88332

View File

@@ -345,6 +345,30 @@ class Config
end
end
# Check if the domain configuration is valid
if (domain = config.domain)
if parsed_domain = begin
URI.parse(domain)
rescue ex
puts "Config (Hint): Failed to parse domain. Please check it's value!"
exit(1)
end
if port = parsed_domain.path.to_i?
puts "Config (Hint): Remove the port from your domain: ':#{port}'"
exit(1)
end
if (path_items = parsed_domain.path.split("/")).size > 1
path = path_items[1..].join("/")
puts "Config (Hint): Remove the path from your domain: '/#{path}'"
exit(1)
end
if scheme = parsed_domain.scheme.presence
puts "Config (Hint): Remove the scheme from your domain: '#{scheme}://'"
exit(1)
end
end
end
return config
end
end