resolve URL for correct favicon downloading, fixes #240 #238

This commit is contained in:
thez3ro 2017-06-29 19:54:49 +02:00 committed by Janek Bevendorff
parent 98c812a297
commit 35c6df2535
6 changed files with 39 additions and 5 deletions

View file

@ -237,6 +237,11 @@ QString Entry::url() const
return m_attributes->value(EntryAttributes::URLKey);
}
QString Entry::webUrl() const
{
return resolveUrl(m_attributes->value(EntryAttributes::URLKey));
}
QString Entry::username() const
{
return m_attributes->value(EntryAttributes::UserNameKey);
@ -784,3 +789,23 @@ QString Entry::resolvePlaceholder(const QString& str) const
return result;
}
QString Entry::resolveUrl(const QString& url) const
{
QString newurl = url;
if (!url.contains("://")) {
// URL doesn't have a protocol, add https by default
newurl.prepend("https://");
}
QUrl uurl = QUrl(newurl);
if(uurl.scheme() == "cmd") {
// URL is a cmd, hopefully the second argument it's an URL
QStringList cmd = newurl.split(" ");
return resolveUrl(cmd[1].remove("'").remove("\""));
} else if(uurl.scheme() != "http" && uurl.scheme() != "https") {
// URL isn't very nice
return QString("");
}
return uurl.url();
}