Sha256: f4522176b445f57522d3e445d1628323dcb3d19ec86209429a650bce85b7eef9
Contents?: true
Size: 802 Bytes
Versions: 4
Compression:
Stored size: 802 Bytes
Contents
require 'uri' class RedirectUriValidator < ActiveModel::EachValidator def self.native_redirect_uri Doorkeeper.configuration.native_redirect_uri end def validate_each(record, attribute, value) if value.blank? record.errors.add(attribute, :blank) else value.split.each do |val| uri = ::URI.parse(val) return if native_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? end end rescue URI::InvalidURIError record.errors.add(attribute, :invalid_uri) end private def native_redirect_uri?(uri) self.class.native_redirect_uri.present? && uri.to_s == self.class.native_redirect_uri.to_s end end
Version data entries
4 entries across 4 versions & 1 rubygems