Imported Upstream version 14.30.0
[platform/upstream/libzypp.git] / zypp / url / UrlBase.cc
index f9fa8f2..5238d52 100644 (file)
@@ -9,10 +9,10 @@
 /**
  * \file zypp/url/UrlBase.cc
  */
-#include <zypp/url/UrlBase.h>
-#include <zypp/base/String.h>
-#include <zypp/base/Gettext.h>
-#include <zypp/base/Regex.h>
+#include "zypp/url/UrlBase.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+#include "zypp/base/Regex.h"
 
 #include <stdexcept>
 #include <climits>
@@ -231,7 +231,11 @@ namespace zypp
                   const std::string &querystr,
                   const std::string &fragment)
     {
-      setScheme(scheme);
+      if ( scheme.empty() && *pathdata.c_str() == '/' )
+       setScheme("file");
+      else
+       setScheme(scheme);
+
       setAuthority(authority);
       setPathData(pathdata);
       setQueryString(querystr);
@@ -850,10 +854,8 @@ namespace zypp
           setUsername(s.substr(0, p), zypp::url::E_ENCODED);
         s = s.substr(p+1);
       }
-      q = s.rfind(']');
-      if ((p = s.rfind(':')) != std::string::npos && p > q+1)
+      if ((p = s.rfind(':')) != std::string::npos && ( (q = s.rfind(']')) == std::string::npos || q < p) )
       {
-
         setHost(s.substr(0, p));
         setPort(s.substr(p+1));
       }
@@ -1248,6 +1250,15 @@ namespace zypp
           setQueryStringMap(pmap);
     }
 
+    // ---------------------------------------------------------------
+    void
+    UrlBase::delQueryParam(const std::string &param)
+    {
+          zypp::url::ParamMap pmap( getQueryStringMap(zypp::url::E_DECODED));
+          pmap.erase(param);
+          setQueryStringMap(pmap);
+    }
+
 
     // ---------------------------------------------------------------
     std::string