File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
src/main/java/com/sshtools/uhttpd Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 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>
Original file line number Diff line number Diff 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 () {
You can’t perform that action at this time.
0 commit comments