From 93e9f2a2a26f60e2a09bda1f8f72a6929f66e418 Mon Sep 17 00:00:00 2001 From: jrobinso <933148+jrobinso@users.noreply.github.com> Date: Sat, 25 Jan 2025 15:09:55 -0800 Subject: [PATCH] Bug fix -- support local path hub.txt files (for testing) --- src/main/java/org/broad/igv/ucsc/Hub.java | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/broad/igv/ucsc/Hub.java b/src/main/java/org/broad/igv/ucsc/Hub.java index 2c9e7ff46..86c6db14b 100644 --- a/src/main/java/org/broad/igv/ucsc/Hub.java +++ b/src/main/java/org/broad/igv/ucsc/Hub.java @@ -44,12 +44,19 @@ private Hub(String url) throws IOException { String baseURL = url.substring(0, idx + 1); this.baseURL = baseURL; - try { - this.host = "https://" + (new URL(url)).getHost(); - } catch (MalformedURLException e) { - // This should never happen - log.error("Error parsing base URL host", e); - throw new RuntimeException(e); + if(url.startsWith("https://") || url.startsWith("http://")) { + try { + URL tmp = new URL(url); + this.host = tmp.getProtocol() + "://" + tmp.getHost(); + } catch (MalformedURLException e) { + // This should never happen + log.error("Error parsing base URL host", e); + throw new RuntimeException(e); + } + } + else { + // Local file, no host + this.host = ""; } List stanzas = loadStanzas(url); @@ -68,6 +75,8 @@ private Hub(String url) throws IOException { throw new RuntimeException("Unexpected hub file -- expected 'genome' stanza but found " + stanzas.get(1).type); } + this.hub = stanzas.get(0); + // Load groups this. genomeStanza = stanzas.get(1); if (genomeStanza.hasProperty("groups")) {