summaryrefslogtreecommitdiff
path: root/lib/gitlab/url_helpers.rb
blob: 883585c196f2262d38336d384eea15ff84177e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

module Gitlab
  class UrlHelpers
    WSS_PROTOCOL = "wss".freeze
    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
  end
end