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