Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N5URI containerPath behavior #121

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: N5URI.from
  • Loading branch information
bogovicj committed Apr 25, 2024
commit 83822b106c69cc2cce72ccc898aa5ce1f1790cca
14 changes: 3 additions & 11 deletions src/main/java/org/janelia/saalfeldlab/n5/N5URI.java
Original file line number Diff line number Diff line change
Expand Up @@ -600,35 +600,27 @@ 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());
buildUri.append("?");
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);
Expand Down
Loading