Skip to content
Open
Changes from all commits
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
17 changes: 17 additions & 0 deletions src/invidious/config.cr
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,23 @@
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 domain != parsed_domain.domain
puts "Config: 'domain' is invalid.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
puts "Config: 'domain' is invalid.
puts "Config: 'domain' is invalid."

if parsed_domain.host.presence
puts "Config: (Hint) Did you mean #{parsed_domain.host} ?"

Check failure on line 331 in src/invidious/config.cr

View workflow job for this annotation

GitHub Actions / build - crystal: 1.13.3, stable: true

unexpected token: "Config"

Check failure on line 331 in src/invidious/config.cr

View workflow job for this annotation

GitHub Actions / build - crystal: 1.12.2, stable: true

unexpected token: "Config"

Check failure on line 331 in src/invidious/config.cr

View workflow job for this annotation

GitHub Actions / build - crystal: 1.15.1, stable: true

unexpected token: "Config"

Check failure on line 331 in src/invidious/config.cr

View workflow job for this annotation

GitHub Actions / build - crystal: 1.14.1, stable: true

unexpected token: "Config"

Check failure on line 331 in src/invidious/config.cr

View workflow job for this annotation

GitHub Actions / build - crystal: 1.16.3, stable: true

unexpected token: "Config"
else
puts "Config: (Hint) 'domain' should look like this: invidious.example.com"
end
exit(1)
end
end

return config
end
end
Loading