Skip to content

Commit f70297e

Browse files
committed
Static middleware fix
1 parent 5abb6a0 commit f70297e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/express/http/response/Response.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private void sendHeaders() {
154154
try {
155155

156156
// Fallback
157-
String contentType = getContentType().getMIME() == null ? MediaType._bin.getMIME() : getContentType().getMIME();
157+
String contentType = getContentType().getExtension() == null ? MediaType._bin.getExtension() : getContentType().getMIME();
158158

159159
// Set header and send response
160160
this.HEADER.set("Content-Type", contentType);

src/express/utils/MediaType.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ public enum MediaType {
695695
private String MIME;
696696
private String extension;
697697

698-
MediaType(String MIME, String extension) {
699-
this.MIME = MIME;
698+
MediaType(String extension, String mime) {
699+
this.MIME = mime;
700700
this.extension = extension;
701701
}
702702

src/express/utils/Utils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ public static String getYourIp() throws UnknownHostException {
7878
*/
7979
public static String getExtension(@NotNull File file) {
8080
String path = file.getAbsolutePath();
81-
return path.substring(path.lastIndexOf('.'));
81+
int indx = path.lastIndexOf('.') + 1;
82+
if (indx == 0)
83+
return null;
84+
85+
return path.substring(indx);
8286
}
8387

8488
}

0 commit comments

Comments
 (0)