attempting fix for Windows file:/// URI

Former-commit-id: 53b125270575b436626f77e15c0d0ab801d075cb
This commit is contained in:
Jeremy Long
2013-08-04 14:44:53 -04:00
parent 458f9a7a63
commit ecf2036064

View File

@@ -130,10 +130,19 @@ public final class Downloader {
public static long getLastModified(URL url) throws DownloadFailedException {
long timestamp = 0;
//TODO add the FPR protocol?
if ("file:".equalsIgnoreCase(url.getProtocol())) {
if ("file".equalsIgnoreCase(url.getProtocol())) {
File f;
try {
f = new File(url.toURI());
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
String filePath = url.toString();
if (filePath.matches("file://[a-zA-Z]:.*")) {
f = new File(filePath.substring(7));
} else {
f = new File(url.toURI());
}
} else {
f = new File(url.toURI());
}
} catch (URISyntaxException ex) {
final String msg = String.format("Unable to locate '%s'; is the cve.url-2.0.modified property set correctly?", url.toString());
throw new DownloadFailedException(msg);