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
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.allowed_schemes_with_suffix ⇒ Object
40 41 42 |
# File 'app/models/katgut/rule.rb', line 40 def allowed_schemes_with_suffix ALLOWED_SCHEMES.map {|s| "#{s}://" } end |
.unallowed_scheme_in?(url) ⇒ Boolean
44 45 46 47 48 49 50 51 52 |
# File 'app/models/katgut/rule.rb', line 44 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
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/katgut/rule.rb', line 24 def regular_destination if URI.extract(destination).present? destination else case destination when /\A\// destination else "#{self.class::DEFAULT_SCHEME}://#{destination}" end end end |