3232
3333package org .scijava .io .location ;
3434
35+ import java .io .File ;
3536import java .net .URI ;
3637import java .net .URISyntaxException ;
3738
@@ -50,25 +51,29 @@ public interface LocationService extends HandlerService<URI, LocationResolver>,
5051
5152 /**
5253 * Turns the given string into an {@link URI}, then resolves it to a
53- * {@link Location}
54- *
55- * @param uri the uri to resolve
54+ * {@link Location}.
55+ *
56+ * @param uriString the uri to resolve
5657 * @return the resolved {@link Location}
5758 * @throws URISyntaxException if the URI is malformed
5859 */
59- default Location resolve (final String uri ) throws URISyntaxException {
60- return resolve (new URI (uri ));
60+ default Location resolve (final String uriString ) throws URISyntaxException {
61+ return resolve (new URI (uriString ));
6162 }
6263
6364 /**
64- * Resolves the given {@link URI} to a location.
65- *
65+ * Resolves the given {@link URI} to a location. If the {@code scheme} part of
66+ * the URI is {@code null} the path component is resolved as a local file.
67+ *
6668 * @param uri the uri to resolve
6769 * @return the resolved {@link Location} or <code>null</code> if no resolver
6870 * could be found.
6971 * @throws URISyntaxException if the URI is malformed
7072 */
71- default Location resolve (final URI uri ) throws URISyntaxException {
73+ default Location resolve (URI uri ) throws URISyntaxException {
74+ if (uri .getScheme () == null ) { // Fallback for local files
75+ uri = new File (uri .getPath ()).toURI ();
76+ }
7277 final LocationResolver resolver = getResolver (uri );
7378 return resolver != null ? resolver .resolve (uri ) : null ;
7479 }
0 commit comments