Created
February 4, 2015 08:04
-
-
Save runexec/bb94efad4b4eb00dbc37 to your computer and use it in GitHub Desktop.
Websocket Path Resolution in ClojureScript.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn current-web-port [] | |
(as-> js/document x | |
(-> x .-URL str) | |
(or (re-find #":(\d+)/" x) | |
(re-find #":(\d+)" x)) | |
(or (last x) 80))) | |
(defn current-domain [] (.-domain js/document)) | |
(defn websocket-path [& [path]] | |
(str "ws://" | |
(current-domain) | |
":" | |
(current-web-port) | |
(or path "/ws"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment