Skip to content

Commit d1675af

Browse files
committed
Release 0.9.15. Still issues on windows (windows file based classpath resources).
1 parent 67403b4 commit d1675af

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<modelVersion>4.0.0</modelVersion>
2020
<groupId>com.sshtools</groupId>
2121
<artifactId>uhttpd</artifactId>
22-
<version>0.9.14</version>
22+
<version>0.9.15</version>
2323
<name>µTTPD - A very small HTTP/HTTPS server</name>
2424
<properties>
2525
<maven.compiler.target>11</maven.compiler.target>

src/main/java/com/sshtools/uhttpd/UHTTPD.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6371,7 +6371,7 @@ public void get(Transaction req) throws Exception {
63716371
var lastMod = OffsetDateTime.ofInstant(Instant.ofEpochMilli(conx.getLastModified()), UTC_ZONE);
63726372
if(req.modified(lastMod)) {
63736373
req.responseLength(conx.getContentLengthLong());
6374-
req.responseType(bestMimeType(urlToFilename(url), conx.getContentType()));
6374+
req.responseType(bestMimeType(uriToFilename(url.toURI()), conx.getContentType()));
63756375
req.response(url.openStream());
63766376
}
63776377
}
@@ -6667,7 +6667,14 @@ public static String urlToFilename(URL url) {
66676667
}
66686668

66696669
public static String uriToFilename(URI uri) {
6670-
return Paths.get(uri.getPath()).getFileName().toString();
6670+
var path = uri.getPath();
6671+
while(path.endsWith("/"))
6672+
path = path.substring(1);
6673+
var idx = path.lastIndexOf('/');
6674+
if(idx == -1)
6675+
return path;
6676+
else
6677+
return path.substring(idx + 1);
66716678
}
66726679

66736680
public static RootContextBuilder server() {

0 commit comments

Comments
 (0)