Fix error when listing MIAA databases (#14286)

This commit is contained in:
Charles Gagnon
2021-02-12 17:16:11 -08:00
committed by GitHub
parent 415689de9f
commit 238a0c60d9

View File

@@ -198,12 +198,16 @@ export function getErrorMessage(error: any, useMessageWithLink: boolean = false)
/**
* Parses an address into its separate ip and port values. Address must be in the form <ip>:<port>
* or <ip>,<port>
* @param address The address to parse
*/
export function parseIpAndPort(address: string): { ip: string, port: string } {
const sections = address.split(':');
let sections = address.split(':');
if (sections.length !== 2) {
throw new Error(`Invalid address format for ${address}. Address must be in the form <ip>:<port>`);
sections = address.split(',');
if (sections.length !== 2) {
throw new Error(`Invalid address format for ${address}. Address must be in the form <ip>:<port> or <ip>,<port>`);
}
}
return {
ip: sections[0],