summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-11-15 20:10:56 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-11-15 20:10:56 (GMT)
commit7164dc98cfd39387fb6c17b8a4a171bfdfb84bd5 (patch)
tree79f06322708983225d69cf8d2d6fc260783d91f1
parentef9310e726e28b730546911ccb55e9611b5a05b6 (diff)
Graciously add http:// if a website tag lacks it.
Note that tagging rules consider the lack of an url scheme an error, i.e. such tags should be fixed in the osm database really.
-rw-r--r--src/lib/marble/declarative/Placemark.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/lib/marble/declarative/Placemark.cpp b/src/lib/marble/declarative/Placemark.cpp
index 1f9f0c7..53d0cdb 100644
--- a/src/lib/marble/declarative/Placemark.cpp
+++ b/src/lib/marble/declarative/Placemark.cpp
@@ -150,9 +150,19 @@ QString Placemark::website() const
return m_website;
}
foreach(const QString &tag, QStringList() << "website" << "contact:website" << "facebook" << "contact:facebook" << "url") {
- m_website = m_placemark.osmData().tagValue(tag);
- if (!m_website.isEmpty()) {
- return m_website;
+ QString const value = m_placemark.osmData().tagValue(tag);
+ if (!value.isEmpty()) {
+ QUrl url = QUrl(value);
+ if (url.isValid()) {
+ if (url.scheme().isEmpty()) {
+ m_website = QStringLiteral("http://%1").arg(value);
+ } else {
+ m_website = value;
+ }
+ if (!m_website.isEmpty()) {
+ return m_website;
+ }
+ }
}
}