From 69e7990afbfc92e8367b6bfff5b68467bc31e9c6 Mon Sep 17 00:00:00 2001 From: m1k1o Date: Wed, 10 Mar 2021 23:02:34 +0100 Subject: [PATCH] relative websocket URL. --- client/src/neko/base.ts | 2 +- client/src/neko/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/neko/base.ts b/client/src/neko/base.ts index 16797af7..9cad66fd 100644 --- a/client/src/neko/base.ts +++ b/client/src/neko/base.ts @@ -59,7 +59,7 @@ export abstract class BaseClient extends EventEmitter { this[EVENT.CONNECTING]() try { - this._ws = new WebSocket(`${url}ws?password=${password}`) + this._ws = new WebSocket(`${url}?password=${encodeURIComponent(password)}`) this.emit('debug', `connecting to ${this._ws.url}`) this._ws.onmessage = this.onMessage.bind(this) this._ws.onerror = (event) => this.onError.bind(this) diff --git a/client/src/neko/index.ts b/client/src/neko/index.ts index 97eb7e1f..6ef7dd4a 100644 --- a/client/src/neko/index.ts +++ b/client/src/neko/index.ts @@ -33,8 +33,8 @@ export class NekoClient extends BaseClient implements EventEmitter { init(vue: Vue) { const url = process.env.NODE_ENV === 'development' - ? `ws://${location.host.split(':')[0]}:${process.env.VUE_APP_SERVER_PORT}/` - : `${/https/gi.test(location.protocol) ? 'wss' : 'ws'}://${location.host}/` + ? `ws://${location.host.split(':')[0]}:${process.env.VUE_APP_SERVER_PORT}/ws` + : location.href.replace(/^http/, 'ws').replace(/\/$/, '')+'/ws' this.initWithURL(vue, url) }