mirror of
https://github.com/RipMeApp/ripme.git
synced 2025-08-21 21:15:19 +02:00
check if empty for filename and extension, not double add extension
This commit is contained in:
@@ -395,18 +395,17 @@ public abstract class AbstractRipper
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getFileName(URL url, String fileName, String extension) {
|
public static String getFileName(URL url, String fileName, String extension) {
|
||||||
if (fileName == null) {
|
if (fileName == null || fileName.trim().isEmpty()) {
|
||||||
fileName = url.toExternalForm();
|
fileName = url.toExternalForm();
|
||||||
fileName = fileName.substring(fileName.lastIndexOf('/')+1);
|
fileName = fileName.substring(fileName.lastIndexOf('/')+1);
|
||||||
}
|
}
|
||||||
if (extension == null) {
|
if (extension == null || extension.trim().isEmpty()) {
|
||||||
// Get the extension of the file
|
// Get the extension of the file
|
||||||
String[] lastBitOfURL = url.toExternalForm().split("/");
|
String[] lastBitOfURL = url.toExternalForm().split("/");
|
||||||
|
|
||||||
String[] lastBit = lastBitOfURL[lastBitOfURL.length - 1].split(".");
|
String[] lastBit = lastBitOfURL[lastBitOfURL.length - 1].split(".");
|
||||||
if (lastBit.length != 0) {
|
if (lastBit.length != 0) {
|
||||||
extension = lastBit[lastBit.length - 1];
|
extension = lastBit[lastBit.length - 1];
|
||||||
fileName = fileName + "." + extension;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user