X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FHtml.java;h=f66032bfce20032f784b6df0ab4b51ce7883fce7;hb=86d49dbc7c3eca665b7823b5de49bb73a31c7722;hp=8dec5f75d55eac093a8808df1a5023da81251dc0;hpb=e4fa48a0b617e0a5368e8e8589909ae93c340447;p=nikiroo-utils.git diff --git a/src/be/nikiroo/fanfix/supported/Html.java b/src/be/nikiroo/fanfix/supported/Html.java index 8dec5f7..f66032b 100644 --- a/src/be/nikiroo/fanfix/supported/Html.java +++ b/src/be/nikiroo/fanfix/supported/Html.java @@ -22,14 +22,17 @@ class Html extends InfoText { @Override protected boolean supports(URL url) { - if (url.getPath().toLowerCase() - .endsWith(File.separatorChar + "index.html")) { - try { - File file = new File(url.toURI()).getParentFile(); - return super.supports(file.toURI().toURL()); - } catch (URISyntaxException e) { - } catch (MalformedURLException e) { + try { + File file = new File(url.toURI()); + if (file.getName().equals("index.html")) { + file = file.getParentFile(); } + + file = new File(file, file.getName()); + + return super.supports(file.toURI().toURL()); + } catch (URISyntaxException e) { + } catch (MalformedURLException e) { } return false; @@ -37,17 +40,22 @@ class Html extends InfoText { @Override public URL getCanonicalUrl(URL source) { - if (source.toString().endsWith(File.separator + "index.html")) { - try { - File fakeFile = new File(source.toURI()); // "story/index.html" - fakeFile = new File(fakeFile.getParent()); // "story" - fakeFile = new File(fakeFile, fakeFile.getName()); // "story/story" - return fakeFile.toURI().toURL(); - } catch (Exception e) { - Instance.getTraceHandler().error( - new IOException("Cannot find the right URL for " - + source, e)); + + try { + File fakeFile = new File(source.toURI()); + if (fakeFile.getName().equals("index.html")) { // "story/index.html" + fakeFile = new File(fakeFile.getParent()); // -> "story/" } + + if (fakeFile.isDirectory()) { // "story/" + fakeFile = new File(fakeFile, fakeFile.getName() + ".txt"); // "story/story.txt" + } + + return fakeFile.toURI().toURL(); + } catch (Exception e) { + Instance.getTraceHandler().error( + new IOException("Cannot find the right URL for " + source, + e)); } return source;