Added precaution for URLs with slashes at the end when determining file name

Made for my FurAffinity branch, brought it over to master branch because
it could come in handy for other things.
This commit is contained in:
Wiiplay123 2017-05-14 20:15:27 -05:00
parent 624c28befa
commit 3d359be958

View File

@ -142,6 +142,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper {
} }
public String fileNameFromURL(URL url) { public String fileNameFromURL(URL url) {
String saveAs = url.toExternalForm(); String saveAs = url.toExternalForm();
if (saveAs.substring(saveAs.length() - 1) == "/") { saveAs = saveAs.substring(0,saveAs.length() - 1) ;}
saveAs = saveAs.substring(saveAs.lastIndexOf('/')+1); saveAs = saveAs.substring(saveAs.lastIndexOf('/')+1);
if (saveAs.indexOf('?') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('?')); } if (saveAs.indexOf('?') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('?')); }
if (saveAs.indexOf('#') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('#')); } if (saveAs.indexOf('#') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('#')); }