Fix error when listing MIAA databases (#14286) (#14289)

(cherry picked from commit 238a0c60d9)
This commit is contained in:
Charles Gagnon
2021-02-13 20:02:28 -08:00
committed by GitHub
parent 3419dd5498
commit 0423480148

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],