From 8a33c9b3092da78ded7fc0fe5b722020ec365fb7 Mon Sep 17 00:00:00 2001 From: theli Date: Mon, 3 Oct 2005 10:21:13 +0000 Subject: [PATCH] *) 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 --- source/de/anomic/plasma/plasmaParser.java | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.java index 650c75b37..3db3e0d84 100644 --- a/source/de/anomic/plasma/plasmaParser.java +++ b/source/de/anomic/plasma/plasmaParser.java @@ -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); } + + // tetermining last position of / in the file path + p = name.lastIndexOf('/'); + if (p != -1) { + name = name.substring(p); + } - p = name.lastIndexOf('.'); + // 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)); }