@@ -51,21 +51,25 @@ void ResourceResolver::resolveNode(const std::string &method, const std::string
5151 size_t nextparamIdx = url.find (' &' , reqparamIdx);
5252
5353 // Get the "name=value" string
54- std::string param = url.substr (reqparamIdx, nextparamIdx - reqparamIdx);
55-
56- // Find the position where the string has to be split
57- size_t nvSplitIdx = param.find (' =' );
54+ std::string param = nextparamIdx == std::string::npos ?
55+ url.substr (reqparamIdx) :
56+ url.substr (reqparamIdx, nextparamIdx - reqparamIdx);
57+
58+ if (param.length () > 0 ) {
59+ // Find the position where the string has to be split
60+ size_t nvSplitIdx = param.find (' =' );
61+
62+ // Use empty string if only name is set. /foo?bar&baz=1 will return "" for bar
63+ std::string name = urlDecode (param.substr (0 , nvSplitIdx));
64+ std::string value = " " ;
65+ if (nvSplitIdx != std::string::npos) {
66+ value = urlDecode (param.substr (nvSplitIdx+1 ));
67+ }
5868
59- // Use empty string if only name is set. /foo?bar&baz=1 will return "" for bar
60- std::string name = param.substr (0 , nvSplitIdx);
61- std::string value = " " ;
62- if (nvSplitIdx != std::string::npos) {
63- value = urlDecode (param.substr (nvSplitIdx+1 ));
69+ // Now we finally have name and value.
70+ params->setQueryParameter (name, value);
6471 }
6572
66- // Now we finally have name and value.
67- params->setQueryParameter (name, value);
68-
6973 // Update reqparamIdx
7074 reqparamIdx = nextparamIdx;
7175
0 commit comments