From 83822b106c69cc2cce72ccc898aa5ce1f1790cca Mon Sep 17 00:00:00 2001 From: John Bogovic Date: Thu, 25 Apr 2024 16:48:49 -0400 Subject: [PATCH] refactor: N5URI.from --- .../java/org/janelia/saalfeldlab/n5/N5URI.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/janelia/saalfeldlab/n5/N5URI.java b/src/main/java/org/janelia/saalfeldlab/n5/N5URI.java index 288bd27..c655abe 100644 --- a/src/main/java/org/janelia/saalfeldlab/n5/N5URI.java +++ b/src/main/java/org/janelia/saalfeldlab/n5/N5URI.java @@ -600,19 +600,15 @@ public static N5URI from( */ public static N5URI from(final String uriOrPath) { - URI uri = null; try { - uri = new URI(uriOrPath); -// System.out.println("direct uri: " + uri.toString()); - return new N5URI(uri); + return new N5URI(new URI(uriOrPath)); } catch (Throwable ignore) {} try { final String[] split = uriOrPath.split("\\?"); final URI tmp = Paths.get(split[0]).toUri(); - System.out.println("tmp: " + tmp.toString()); if (split.length == 1) - uri = tmp; + return new N5URI(tmp); else { StringBuffer buildUri = new StringBuffer(); buildUri.append(tmp.toString()); @@ -620,15 +616,11 @@ public static N5URI from(final String uriOrPath) { for (int i = 1; i < split.length; i++) buildUri.append(split[i]); - uri = new URI(buildUri.toString()); -// System.out.println("path uri: " + uri.toString()); - return new N5URI(uri); + return new N5URI(new URI(buildUri.toString())); } } catch (Throwable ignore) {} try { - uri = N5URI.encodeAsUri(uriOrPath); -// System.out.println("encoded uri: " + uri.toString()); return new N5URI(N5URI.encodeAsUri(uriOrPath)); } catch (URISyntaxException e) { throw new N5Exception(e);