*) Bugfix: supportedFileExt Function didn't detect the file extension correctly if there was a dot

in one of the parent directories of the file.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@836 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 20 years ago
parent 28c5687ff9
commit 8a33c9b309

@ -257,6 +257,14 @@ public final class plasmaParser {
}
}
public static boolean supportedContent(URL url, String mimeType) {
return supportedMimeTypesContains(mimeType) && supportedFileExt(url);
}
public static boolean supportedRealTimeContent(URL url, String mimeType) {
return realtimeParsableMimeTypesContains(mimeType) && supportedFileExt(url);
}
public static boolean supportedMimeTypesContains(String mimeType) {
mimeType = getRealMimeType(mimeType);
@ -270,13 +278,23 @@ public final class plasmaParser {
}
public static boolean supportedFileExt(URL url) {
// getting the file path
String name = url.getFile();
// chopping http parameters from the url
int p = name.lastIndexOf('?');
if (p != -1) {
name = name.substring(0,p);
}
p = name.lastIndexOf('.');
// tetermining last position of / in the file path
p = name.lastIndexOf('/');
if (p != -1) {
name = name.substring(p);
}
// termining last position of . in file path
p = (p != -1) ? name.lastIndexOf('.',p) : name.lastIndexOf('.');
if (p < 0) return true; // seams to be strange, but this is a directory entry or default file (html)
return supportedFileExtContains(name.substring(p + 1));
}

Loading…
Cancel
Save