Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ class Config
end
end

# Check if the domain configuration is valid
if (domain = config.domain).nil? || domain.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way you can use String.presence instead of a separate nil/empty check

Suggested change
if (domain = config.domain).nil? || domain.empty?
if !config.domain.presence

puts "Config: 'domain' is required/can't be empty"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

domain can be empty on local instances.

exit(1)
elsif parsed_domain = URI.parse(domain)
if !parsed_domain.scheme.nil?
puts "Config: 'domain' cannot contain a scheme (#{parsed_domain.scheme})"
puts "Config: (Hint) Set 'domain' to '#{parsed_domain.host}'"
exit(1)
end
end

return config
end
end
Loading