class Redirect
Constants
- STRING_HANDLING_OPTIONS
- TYPES
Private Instance Methods
destination_formatting()
click to toggle source
# File lib/buweb/redirect.rb, line 27 def destination_formatting if destination.present? unless (uri?(destination) || valid_relative_url?(destination)) errors.add :base, 'The destination either needs to be a full url or a valid relative url.' end end end
uri?(string)
click to toggle source
# File lib/buweb/redirect.rb, line 35 def uri?(string) uri = URI.parse(string) %w( http https ).include?(uri.scheme) rescue URI::BadURIError false rescue URI::InvalidURIError false end
valid_relative_url?(string)
click to toggle source
# File lib/buweb/redirect.rb, line 44 def valid_relative_url?(string) string.starts_with?('/') end