Sha256: 4b67ec0309f9e6c4bbc648407448cd7a44554ec3bf67cea391b67907b99bd994

Contents?: true

Size: 660 Bytes

Versions: 1

Compression:

Stored size: 660 Bytes

Contents

# frozen_string_literal: true

unless Hash.method_defined?(:stringify_keys)
  class Hash
    # via https://stackoverflow.com/a/25835016/2257038
    def stringify_keys
      h = self.map do |k, v|
        v_str = if v.instance_of? Hash
            v.stringify_keys
          else
            v
          end

        [k.to_s, v_str]
      end
      Hash[h]
    end
  end
end

module LiveKit
  module Utils
    def to_http_url(url)
      if url.start_with?("ws")
        # replace ws prefix to http
        return url.sub(/^ws/, "http")
      else
        return url
      end
    end

    module_function :to_http_url
  end
end
# convert websocket urls to http

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
livekit-server-sdk-0.6.5 lib/livekit/utils.rb