Class: Utilities::Urls
- Inherits:
-
Object
- Object
- Utilities::Urls
- Defined in:
- lib/fingerprinter/utilities/urls.rb
Overview
Urls : Utilities related to urls
Class Method Summary collapse
Class Method Details
.up_to_port(url) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/fingerprinter/utilities/urls.rb', line 14 def self.up_to_port(url) uri = url.is_a?(URI) ? url : uri_parse(url) return unless uri url = "#{uri.scheme}://#{uri.host}" url += ":#{uri.port}" unless [80, 443].include?(uri.port) url end |
.uri_parse(url) ⇒ Object
8 9 10 11 12 |
# File 'lib/fingerprinter/utilities/urls.rb', line 8 def self.uri_parse(url) URI(url) rescue ArgumentError, URI::InvalidURIError nil end |
.without_query(url) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/fingerprinter/utilities/urls.rb', line 24 def self.without_query(url) uri = url.is_a?(URI) ? url : uri_parse(url) return unless uri uri.to_s.split('?', 2).first.to_s end |