0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 10:40:48 +08:00
discourse/lib/validators/content_localization_crawler_param_validator.rb
Natalie Tay 16919c4fd4
UX: Prevent incomplete crawler localization settings (#41297)
This PR makes sure crawler localization URLs only work when anonymous
users can resolve the locale from the URL param. This blocks enabling
the crawler param without that prerequisite and keeps hreflang,
canonical URLs, and crawler link rewriting behind the same guard.

/406195/4
2026-07-01 12:13:22 +08:00

16 lines
342 B
Ruby
Vendored

# frozen_string_literal: true
class ContentLocalizationCrawlerParamValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(val)
return true if val == "f"
SiteSetting.set_locale_from_param
end
def error_message
I18n.t("site_settings.errors.content_localization_crawler_param_requirements")
end
end