Class: Gitlab::UrlHelpers
- Inherits:
-
Object
- Object
- Gitlab::UrlHelpers
- Defined in:
- lib/gitlab/url_helpers.rb
Constant Summary collapse
- WSS_PROTOCOL =
"wss"
Class Method Summary collapse
- .as_wss(url) ⇒ Object
-
.normalized_base_url(url) ⇒ String|Nilclass
Returns hostname of a URL.
Class Method Details
.as_wss(url) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/gitlab/url_helpers.rb', line 6 def self.as_wss(url) return unless url.present? URI.parse(url).tap do |uri| uri.scheme = WSS_PROTOCOL end.to_s rescue URI::InvalidURIError nil end |
.normalized_base_url(url) ⇒ String|Nilclass
Returns hostname of a URL.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gitlab/url_helpers.rb', line 20 def self.normalized_base_url(url) parsed = Utils.parse_url(url) return unless parsed if parsed.port format("%{scheme}://%{host}:%{port}", scheme: parsed.scheme, host: parsed.host, port: parsed.port) else format("%{scheme}://%{host}", scheme: parsed.scheme, host: parsed.host) end end |