fix(xo-lib): handle URLs ending with /

Thanks @rushikeshjadhav
This commit is contained in:
Julien Fontanet
2020-12-15 12:51:20 +01:00
parent a84961f8ba
commit 25d69d1bd7

View File

@@ -1,4 +1,5 @@
import JsonRpcWebSocketClient, { OPEN, CLOSED } from 'jsonrpc-websocket-client'
import trimEnd from 'lodash/trimEnd'
import { BaseError } from 'make-error'
// ===================================================================
@@ -14,7 +15,7 @@ export class XoError extends BaseError {}
export default class Xo extends JsonRpcWebSocketClient {
constructor(opts) {
const url = opts != null ? opts.url : '.'
super(`${url === '/' ? '' : url}/api/`)
super(`${trimEnd(url, '/')}/api/`)
this._credentials = opts != null ? opts.credentials : null
this._user = null