diff options
Diffstat (limited to 'actioncable/app/javascript/action_cable/index.js')
-rw-r--r-- | actioncable/app/javascript/action_cable/index.js | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/actioncable/app/javascript/action_cable/index.js b/actioncable/app/javascript/action_cable/index.js index e679745fd7..848b5631d6 100644 --- a/actioncable/app/javascript/action_cable/index.js +++ b/actioncable/app/javascript/action_cable/index.js @@ -1,6 +1,6 @@ import Connection from "./connection" import ConnectionMonitor from "./connection_monitor" -import Consumer from "./consumer" +import Consumer, { createWebSocketURL } from "./consumer" import INTERNAL from "./internal" import Subscription from "./subscription" import Subscriptions from "./subscriptions" @@ -15,11 +15,12 @@ export { Subscription, Subscriptions, adapters, + createWebSocketURL, logger, } export function createConsumer(url = getConfig("url") || INTERNAL.default_mount_path) { - return new Consumer(createWebSocketURL(url)) + return new Consumer(url) } export function getConfig(name) { @@ -28,18 +29,3 @@ export function getConfig(name) { return element.getAttribute("content") } } - -export function createWebSocketURL(url) { - const webSocketURL = typeof url === "function" ? url() : url - - if (webSocketURL && !/^wss?:/i.test(webSocketURL)) { - const a = document.createElement("a") - a.href = webSocketURL - // Fix populating Location properties in IE. Otherwise, protocol will be blank. - a.href = a.href - a.protocol = a.protocol.replace("http", "ws") - return a.href - } else { - return webSocketURL - } -} |