Allow wss & https endpoints (#96)
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -10,4 +10,10 @@ describe('state', () => {
|
||||
() => state('ws://')
|
||||
).toThrow(/with 'http/);
|
||||
});
|
||||
|
||||
it('allows https:// endpoints', () => {
|
||||
expect(
|
||||
state('https://')
|
||||
).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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<WsState> {
|
||||
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,
|
||||
|
||||
@@ -10,4 +10,10 @@ describe('state', () => {
|
||||
() => state('http://')
|
||||
).toThrow(/with 'ws/);
|
||||
});
|
||||
|
||||
it('allows wss:// endpoints', () => {
|
||||
expect(
|
||||
state('wss://')
|
||||
).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user