- public static isLoopback (address: string): boolean {
- // eslint-disable-next-line no-useless-escape
- return /^localhost$|^127(?:\.\d+){0,2}\.\d+$|^(?:0*\:)*?:?0*1$/i.test(address)
- }
+export const getProtocolAndVersion = (protocolStr: string): [Protocol, ProtocolVersion] => {
+ const protocolIndex = protocolStr.indexOf(Protocol.UI)
+ const protocol = protocolStr.substring(
+ protocolIndex,
+ protocolIndex + Protocol.UI.length
+ ) as Protocol
+ const version = protocolStr.substring(protocolIndex + Protocol.UI.length) as ProtocolVersion
+ return [protocol, version]
+}
+
+export const isLoopback = (address: string): boolean => {
+ // eslint-disable-next-line no-useless-escape
+ return /^localhost$|^127(?:\.\d+){0,2}\.\d+$|^(?:0*\:)*?:?0*1$/i.test(address)