SyntaxFix
Write A Post
Hire A Developer
Questions
easy:
location.href.replace(/^http/, 'ws') + '/to/ws' // or if you hate regexp: location.href.replace('http://', 'ws://').replace('https://', 'wss://') + '/to/ws'