From: Niki Roo Date: Thu, 2 Apr 2020 10:01:01 +0000 (+0200) Subject: correct err message for unsupported URLs X-Git-Tag: fanfix-swing-0.0.1~12^2~7^2 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=3ddb5591128b1f30dc27c4b58c89dc06c53e5d76;p=fanfix-swing.git correct err message for unsupported URLs --- diff --git a/changelog-fr.md b/changelog-fr.md index 9409b81b..79674a42 100644 --- a/changelog-fr.md +++ b/changelog-fr.md @@ -1,5 +1,9 @@ # Fanfix +# Version WIP + +- fix: en cas d'URL non supportée, n'affiche plus un message d'erreur relatif à "file://" + # Version 3.0.0 - new: maintenant compatible Android (voir [companion project](https://gitlab.com/Rayman22/fanfix-android)) diff --git a/changelog.md b/changelog.md index f3033b54..223661bc 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Fanfix +# Version WIP + +- fix: for unsupported URL, do not errors out with a "file://" related message + # Version 3.0.0 - new: now Android-compatible (see [companion project](https://gitlab.com/Rayman22/fanfix-android)) diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index 0974392d..2ed276b1 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -788,7 +788,7 @@ public class Main { try { URL source = BasicReader.getUrl(urlString); sourceName = source.toString(); - if (source.toString().startsWith("file://")) { + if (sourceName.startsWith("file://")) { sourceName = sourceName.substring("file://".length()); } diff --git a/src/be/nikiroo/fanfix/supported/Text.java b/src/be/nikiroo/fanfix/supported/Text.java index daa108fc..8af4a408 100644 --- a/src/be/nikiroo/fanfix/supported/Text.java +++ b/src/be/nikiroo/fanfix/supported/Text.java @@ -288,6 +288,8 @@ class Text extends BasicSupport { /** * Check if we supports this {@link URL}, that is, if the info file can be * found OR not found. + *

+ * It must also be a file, not another kind of URL. * * @param url * the {@link URL} to check @@ -297,21 +299,23 @@ class Text extends BasicSupport { * @return TRUE if it is supported */ protected boolean supports(URL url, boolean info) { - boolean infoPresent = false; - if ("file".equals(url.getProtocol())) { - File file; - try { - file = new File(url.toURI()); - file = assureNoTxt(file); - file = new File(file.getPath() + ".info"); - } catch (URISyntaxException e) { - Instance.getTraceHandler().error(e); - file = null; - } + if (!"file".equals(url.getProtocol())) { + return false; + } - infoPresent = (file != null && file.exists()); + boolean infoPresent = false; + File file; + try { + file = new File(url.toURI()); + file = assureNoTxt(file); + file = new File(file.getPath() + ".info"); + } catch (URISyntaxException e) { + Instance.getTraceHandler().error(e); + file = null; } + infoPresent = (file != null && file.exists()); + return infoPresent == info; }