class RedirectUriValidator
def self.test_redirect_uri
def self.test_redirect_uri Doorkeeper.configuration.test_redirect_uri end
def test_redirect_uri?(uri)
def test_redirect_uri?(uri) self.class.test_redirect_uri.present? && uri.to_s == self.class.test_redirect_uri.to_s end
def validate_each(record, attribute, value)
def validate_each(record, attribute, value) uri = ::URI.parse(value) return if test_redirect_uri?(uri) record.errors.add(attribute, :fragment_present) unless uri.fragment.nil? record.errors.add(attribute, :relative_uri) if uri.scheme.nil? || uri.host.nil? record.errors.add(attribute, :has_query_parameter) unless uri.query.nil? rescue URI::InvalidURIError record.errors.add(attribute, :invalid_uri) end