-updated getHost, similiar to DirectHTTP plugin changes

git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@49673 ebf7c1c2-ba36-0410-9fe8-c592906822b4

Former-commit-id: 4c865041d18e8a8801e3c7f31c8871cb11d0b7e7
This commit is contained in:
jiaz 2024-08-23 23:45:11 +00:00
parent c485a5a610
commit 0d00120df3

View File

@ -28,6 +28,7 @@ import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import org.appwork.utils.StringUtils;
import org.appwork.utils.net.httpconnection.HTTPProxy;
import org.appwork.utils.net.httpconnection.HTTPProxyException;
import org.jdownloader.DomainInfo;
@ -64,11 +65,23 @@ public class Ftp extends PluginForHost {
super(wrapper);
}
public static final String PROPERTY_CUSTOM_HOST = "PROPERTY_CUSTOM_HOST";
@Override
public String getHost(final DownloadLink link, Account account, boolean includeSubdomain) {
if (link != null) {
// prefer domain via public suffic list
return Browser.getHost(link.getDownloadURL(), includeSubdomain);
final String customHost = link.getStringProperty(PROPERTY_CUSTOM_HOST, null);
if (StringUtils.isNotEmpty(customHost)) {
return customHost;
} else {
// prefer domain via public suffic list
String ret = Browser.getHost(link.getPluginPatternMatcher(), includeSubdomain);
if (includeSubdomain) {
// we don't want ftp subdomain
ret = ret != null ? ret.replaceFirst("(?i)^ftp\\.", "") : ret;
}
return ret;
}
} else if (account != null) {
return account.getHoster();
} else {