From dd3b980c36afe3ad75c97abd3d41b512063588b4 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 6 Mar 2023 10:40:46 +0200 Subject: [PATCH] strip path from server url when determining host and port --- src/main/java/com/sparrowwallet/sparrow/net/Protocol.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java b/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java index 37c34d86..81c62c1f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java +++ b/src/main/java/com/sparrowwallet/sparrow/net/Protocol.java @@ -129,7 +129,9 @@ public enum Protocol { public abstract CloseableTransport getTransport(HostAndPort server, File serverCert, HostAndPort proxy) throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException; public HostAndPort getServerHostAndPort(String url) { - return HostAndPort.fromString(url.substring(this.toUrlString().length())); + String lessProtocol = url.substring(this.toUrlString().length()); + int pathStart = lessProtocol.indexOf('/'); + return HostAndPort.fromString(pathStart < 0 ? lessProtocol : lessProtocol.substring(0, pathStart)); } public String toUrlString() {