Imported Upstream version 15.0.0
[platform/upstream/libzypp.git] / zypp / url / UrlBase.cc
index 68ee0e0..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);
@@ -724,7 +728,7 @@ namespace zypp
           config("vsep_pathparam").empty())
       {
         ZYPP_THROW(UrlNotSupportedException(
-          _("Path parameter parsing not supported for this URL")
+          "Path parameter parsing not supported for this URL"
         ));
       }
       zypp::url::ParamMap pmap;
@@ -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));
       }
@@ -1181,7 +1183,7 @@ namespace zypp
           config("vsep_pathparam").empty())
       {
         ZYPP_THROW(UrlNotSupportedException(
-          _("Path Parameter parsing not supported for this URL")
+          "Path Parameter parsing not supported for this URL"
         ));
       }
       setPathParams(
@@ -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
@@ -1320,7 +1331,7 @@ namespace zypp
         {
           struct in6_addr ip;
           std::string temp( host.substr(1, host.size()-2));
-          
+
           return inet_pton(AF_INET6, temp.c_str(), &ip) > 0;
         }
         else