From 83b8b5de61ced05a0696c929972ff345f413d25e Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 13 Apr 2018 16:58:48 +0200 Subject: [PATCH] fix(xo-web/updater): support path prefix Related to #2775 --- packages/xo-web/src/common/xoa-updater.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/xo-web/src/common/xoa-updater.js b/packages/xo-web/src/common/xoa-updater.js index 684e00e4e..b00292314 100644 --- a/packages/xo-web/src/common/xoa-updater.js +++ b/packages/xo-web/src/common/xoa-updater.js @@ -47,21 +47,6 @@ export function blockXoaAccess (xoaState) { return block } -function getCurrentUrl () { - if (typeof window === 'undefined') { - throw new Error('cannot get current URL') - } - return String(window.location) -} - -function adaptUrl (url, port = null) { - const matches = /^http(s?):\/\/([^/:]*(?::[^/]*)?)(?:[^:]*)?$/.exec(url) - if (!matches || !matches[2]) { - throw new Error('current URL not recognized') - } - return 'ws' + matches[1] + '://' + matches[2] + '/api/updater' -} - // =================================================================== export const NotRegistered = makeError('NotRegistered') @@ -211,7 +196,7 @@ class XoaUpdater extends EventEmitter { if (!this._client) { try { - this._client = new Client(adaptUrl(getCurrentUrl())) + this._client = new Client('./api/updater') await this._client.open() handleOpen(this._client) } catch (error) {