aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/app/javascript/action_cable
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/app/javascript/action_cable')
-rw-r--r--actioncable/app/javascript/action_cable/index.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/actioncable/app/javascript/action_cable/index.js b/actioncable/app/javascript/action_cable/index.js
index 659418396f..e679745fd7 100644
--- a/actioncable/app/javascript/action_cable/index.js
+++ b/actioncable/app/javascript/action_cable/index.js
@@ -30,14 +30,16 @@ export function getConfig(name) {
}
export function createWebSocketURL(url) {
- if (url && !/^wss?:/i.test(url)) {
+ const webSocketURL = typeof url === "function" ? url() : url
+
+ if (webSocketURL && !/^wss?:/i.test(webSocketURL)) {
const a = document.createElement("a")
- a.href = url
+ 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 url
+ return webSocketURL
}
}