Standardize construction of websocket URL
authorfeld <feld@feld.me>
Fri, 3 May 2019 11:45:04 +0000 (11:45 +0000)
committerlambda <lain@soykaf.club>
Fri, 3 May 2019 11:45:04 +0000 (11:45 +0000)
This follows up on the change made in d747bd98

lib/pleroma/plugs/http_security_plug.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex

index f701aaaa5cec3b6157a1e08bf5957df52ca9555b..a476f1d49ab2ed02e98b0a1aba677b37f845a541 100644 (file)
@@ -35,7 +35,7 @@ defmodule Pleroma.Plugs.HTTPSecurityPlug do
   defp csp_string do
     scheme = Config.get([Pleroma.Web.Endpoint, :url])[:scheme]
     static_url = Pleroma.Web.Endpoint.static_url()
-    websocket_url = String.replace(static_url, "http", "ws")
+    websocket_url = Pleroma.Web.Endpoint.websocket_url()
 
     connect_src = "connect-src 'self' #{static_url} #{websocket_url}"
 
index ed585098a7b520253e1ce8a258e3670d6d261d31..201a21f50d30c72288324865598917ef7b233208 100644 (file)
@@ -1295,8 +1295,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
       initial_state =
         %{
           meta: %{
-            streaming_api_base_url:
-              String.replace(Pleroma.Web.Endpoint.static_url(), "http", "ws"),
+            streaming_api_base_url: Pleroma.Web.Endpoint.websocket_url(),
             access_token: token,
             locale: "en",
             domain: Pleroma.Web.Endpoint.host(),