Module: Supabase::Realtime::Transformers
- Defined in:
- lib/supabase/realtime/transformers.rb
Overview
Mirrors realtime-py’s ‘realtime.transformers`. Today this is a single helper used to derive the HTTP endpoint from the WebSocket URL so callers can hit the realtime REST surface (e.g. /api/broadcast, /connections).
Class Method Summary collapse
-
.http_endpoint_url(socket_url) ⇒ Object
Converts a realtime socket URL into its HTTP equivalent.
Class Method Details
.http_endpoint_url(socket_url) ⇒ Object
Converts a realtime socket URL into its HTTP equivalent.
http_endpoint_url("wss://x.supabase.co/realtime/v1/websocket")
# => "https://x.supabase.co/realtime/v1"
Replaces the leading ‘ws`/`wss` scheme with `http`/`https`, strips any `/socket/websocket`, `/socket`, or `/websocket` suffix, and trims trailing slashes. Mirrors py’s regex chain verbatim.
19 20 21 22 23 |
# File 'lib/supabase/realtime/transformers.rb', line 19 def http_endpoint_url(socket_url) url = socket_url.to_s.sub(/\Aws/i, "http") url = url.sub(%r{(/socket/websocket|/socket|/websocket)/?\z}i, "") url.sub(%r{/+\z}, "") end |