- wxString query = baseuri.substr(baseuri.find('?') + 1);
- wxString newquery;
- wxStringTokenizer tokenizer(query, ";");
- while(tokenizer.HasMoreTokens())
- {
- wxString token = tokenizer.GetNextToken();
- if(token.substr(0, 5) == "path=")
- {
- wxString path = token.substr(6);
- //Then we remove the last filename
- path = path.BeforeLast('/') + '/';
- //Ensure that we have the leading / so we can normalise properly
- //if(path.substr(0, 1) != "/")
- // path = "/" + path;
-
- //We can now use wxFileName to perform the normalisation
- wxFileName fn(path + newuri);
- fn.Normalize(wxPATH_NORM_DOTS, "", wxPATH_UNIX);
- newquery = newquery + "path=" + fn.GetFullPath(wxPATH_UNIX);
- }
- else
- {
- newquery += token;
- }
- //We need to add the separators back
- if(tokenizer.HasMoreTokens())
- newquery += ';';
- }
- return baseuri.substr(0, baseuri.find('?')) + "?" + newquery;
+ QueryMap map = QueryStringToQueryMap(baseuri.substr(baseuri.find('?')));
+ wxString path = map["path"];
+ //Then we remove the last filename
+ path = path.BeforeLast('/') + '/';
+
+ //We can now use wxFileName to perform the normalisation
+ wxFileName fn(path + newuri);
+ fn.Normalize(wxPATH_NORM_DOTS, "", wxPATH_UNIX);
+ map["path"] = fn.GetFullPath(wxPATH_UNIX);
+
+ wxString newquery = QueryMapToQueryString(map);
+ return baseuri.substr(0, baseuri.find('?')) + newquery;