diff --git a/packages/api-provider/src/http/state.js b/packages/api-provider/src/http/state.js index d308696c11c1..4b7c92bf79ee 100644 --- a/packages/api-provider/src/http/state.js +++ b/packages/api-provider/src/http/state.js @@ -11,7 +11,7 @@ const l = require('@polkadot/util/logger')('api-http'); const coder = require('../coder/json'); module.exports = function state (endpoint: string): HttpState { - assert(/^http:\/\//.test(endpoint), `Endpoint should start with 'http://', received '${endpoint}'`); + assert(/^(https|http):\/\//.test(endpoint), `Endpoint should start with 'http://', received '${endpoint}'`); return { coder: coder(), diff --git a/packages/api-provider/src/http/state.spec.js b/packages/api-provider/src/http/state.spec.js index c9b201e62df2..6a50acb1e612 100644 --- a/packages/api-provider/src/http/state.spec.js +++ b/packages/api-provider/src/http/state.spec.js @@ -10,4 +10,10 @@ describe('state', () => { () => state('ws://') ).toThrow(/with 'http/); }); + + it('allows https:// endpoints', () => { + expect( + state('https://') + ).toBeDefined(); + }); }); diff --git a/packages/api-provider/src/ws/state.js b/packages/api-provider/src/ws/state.js index 9b6a34146229..c93ce0c6ddcf 100644 --- a/packages/api-provider/src/ws/state.js +++ b/packages/api-provider/src/ws/state.js @@ -12,7 +12,7 @@ const l = require('@polkadot/util/logger')('api-ws'); const coder = require('../coder/json'); module.exports = function state (endpoint: string, autoConnect: boolean): $Shape { - assert(/^ws:\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`); + assert(/^(wss|ws):\/\//.test(endpoint), `Endpoint should start with 'ws://', received '${endpoint}'`); return { autoConnect, diff --git a/packages/api-provider/src/ws/state.spec.js b/packages/api-provider/src/ws/state.spec.js index cfee5e4bff65..7372734d15f5 100644 --- a/packages/api-provider/src/ws/state.spec.js +++ b/packages/api-provider/src/ws/state.spec.js @@ -10,4 +10,10 @@ describe('state', () => { () => state('http://') ).toThrow(/with 'ws/); }); + + it('allows wss:// endpoints', () => { + expect( + state('wss://') + ).toBeDefined(); + }); });