discourse/lib/validators/allowed_iframes_validator.rb
Loïc Guitaut a633007bae
DEV: Replace Ruby numbered parameters by it where applicable (#37810)
Now that we moved to Ruby 3.4, we can use `it` instead of `_1`.
2026-02-13 13:59:07 +01:00

18 lines
462 B
Ruby

# frozen_string_literal: true
class AllowedIframesValidator
# Url starts with http:// or https:// and has at least one more additional '/'
VALID_ALLOWED_IFRAME_URL_REGEX = %r{\Ahttps?://([^/]*/)+[^/]*\z}x
def initialize(opts = {})
@opts = opts
end
def valid_value?(values)
values.split("|").all? { it.match? VALID_ALLOWED_IFRAME_URL_REGEX }
end
def error_message
I18n.t("site_settings.errors.invalid_allowed_iframes_url")
end
end