Class: Katgut::Rule
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Katgut::Rule
- Defined in:
- app/models/katgut/rule.rb
Constant Summary collapse
- ALLOWED_SCHEMES =
[:https, :http]
- DEFAULT_SCHEME =
:http
- MINIMUM_SOURCE_LENGTH =
5
- MAXIMUM_DESTINATION_LENGTH =
Limitation for IE / Edge
2083
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.allowed_schemes_with_suffix ⇒ Object
41 42 43 |
# File 'app/models/katgut/rule.rb', line 41 def allowed_schemes_with_suffix ALLOWED_SCHEMES.map {|s| "#{s}://" } end |
.unallowed_scheme_in?(url) ⇒ Boolean
45 46 47 48 49 50 51 52 53 |
# File 'app/models/katgut/rule.rb', line 45 def unallowed_scheme_in?(url) if url.present? !URI.extract(url).all? do |str| ALLOWED_SCHEMES.include? URI.split(str)[0].to_sym end else false end end |
Instance Method Details
#regular_destination ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/katgut/rule.rb', line 25 def regular_destination if URI.extract(destination).present? destination else case destination when /\A\// destination else "#{self.class::DEFAULT_SCHEME}://#{destination}" end end end |