2
0
mirror of https://github.com/tenrok/vue-native-websocket.git synced 2026-06-09 16:02:25 +03:00

Feature handle skip scheme ws url

if skip scheme url, like ` //localhost:8080` ,  add `ws` or
`wss` .
This commit is contained in:
denzow
2018-05-07 21:36:44 +09:00
parent 649485e28b
commit c0f0209fe0
2 changed files with 18 additions and 0 deletions
+4
View File
@@ -3,6 +3,10 @@ import Emitter from './Emitter'
export default class {
constructor (connectionUrl, opts = {}) {
this.format = opts.format && opts.format.toLowerCase()
if(connectionUrl.startsWith('//')){
const scheme = window.location.protocol === 'https:' ? 'wss' : 'ws';
connectionUrl = `${scheme}://${connectionUrl}`
}
this.connectionUrl = connectionUrl
this.opts = opts