Skip to content

Commit

Permalink
Don't convert filename to URL in order to check file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Alpers committed Feb 4, 2025
1 parent 69dffb6 commit 86636c9
Showing 1 changed file with 5 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
package io.goobi.viewer.model.search;

import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -534,16 +530,12 @@ void addSortFieldsToMetadata(StructElement structElement, List<StringPair> sortF
* @should return empty string for unknown file extensions
*/
static String getMimeTypeFromExtension(String filename) {
try {
URL fileUrl = new URI(filename).toURL();
ImageFileFormat format = ImageFileFormat.getImageFileFormatFromFileExtension(fileUrl.getPath());
if (format != null) {
return format.getMimeType();
}
} catch (MalformedURLException | URISyntaxException e) {
logger.warn(e.getMessage());
ImageFileFormat format = ImageFileFormat.getImageFileFormatFromFileExtension(filename);
if (format != null) {
return format.getMimeType();
} else {
return "";
}
return "";
}

/**
Expand Down

0 comments on commit 86636c9

Please sign in to comment.