--- a/libupnpp/upnpplib.cxx
+++ b/libupnpp/upnpplib.cxx
@@ -273,6 +273,20 @@
 	}
 	out += s2;
 	return out;
+}
+
+string baseurl(const string& url)
+{
+    string::size_type pos = url.find("://");
+    if (pos == string::npos)
+        return url;
+
+    pos = url.find_first_of("/", pos + 3);
+    if (pos == string::npos) {
+        return url;
+    } else {
+        return url.substr(0, pos + 1);
+    }
 }
 
 static void path_catslash(string &s) {