chore(core/utils): better error handling when invalid blockchain `endpoint` is defined

This commit is contained in:
Pascal Precht 2020-04-09 16:43:56 +02:00 committed by Pascal Precht
parent deb682c9d2
commit ae56575554
1 changed files with 3 additions and 0 deletions

View File

@ -181,6 +181,9 @@ export function toposort(graph) {
export function deconstructUrl(endpoint) { export function deconstructUrl(endpoint) {
const matches = endpoint.match(/(wss?|https?):\/\/([a-zA-Z0-9_.\/-]*):?([0-9]*)?/); const matches = endpoint.match(/(wss?|https?):\/\/([a-zA-Z0-9_.\/-]*):?([0-9]*)?/);
if (!matches) {
throw new Error(`Couldn't deconstruct blockchain endpoint which needs to be a URL. Got '${endpoint}`);
}
return { return {
protocol: matches[1], protocol: matches[1],
host: matches[2], host: matches[2],