Skip to content

Commit

Permalink
Improve creation of a Path from a URL-like String
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsona committed Feb 28, 2024
1 parent e39edf5 commit 5891129
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.boot.buildpack.platform.build;

import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -51,11 +52,11 @@ Path asPath() {
try {
URL url = new URL(this.value);
if (url.getProtocol().equals("file")) {
return Paths.get(url.getPath());
return Paths.get(url.toURI());
}
return null;
}
catch (MalformedURLException ex) {
catch (MalformedURLException | URISyntaxException ex) {
// not a URL, fall through to attempting to find a plain file path
}
try {
Expand Down

0 comments on commit 5891129

Please sign in to comment.