Skip to content

Bugfix for queryString issue #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 29, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/api.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,11 @@
</cfif>
<!--- query_string input is also key-value pairs --->
<cfloop list="#arguments.queryString#" delimiters="&" index="local.t">
<cfset local.returnData[listFirst(local.t,'=')] = urlDecode(listLast(local.t,'=')) />
<cfif listLen(local.t,'=') eq 2>
<cfset local.returnData[listFirst(local.t,'=')] = urlDecode(listLast(local.t,'=')) />
<cfelse>
<cfset local.returnData[listFirst(local.t,'=')] = "" />
</cfif>
</cfloop>
<!--- if a mime type is requested as part of the url ("whatever.json"), then extract that so taffy can use it --->
<cfif listContainsNoCase(structKeyList(application._taffy.settings.mimeExtensions), listLast(arguments.uri,"."))>
Expand Down
14 changes: 14 additions & 0 deletions tests/tests/TestCore.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,20 @@
assertEquals("hotel", local.deserializedContent["bar"]);
assertEquals("foxtrot", local.deserializedContent["baz"]);
}

function get_queryString_keys_without_values_returns_empty_string() {
makePublic(variables.taffy, "buildRequestArguments");

var returnedArguments = variables.taffy.buildRequestArguments(
regex = "/testResource/(\.[^\.\?]+)?$",
tokenNamesArray = [],
uri = "/testResource/",
queryString = "keyOne=valueOne&keyTwo=&keyThree=valueThree",
headers = {}
);

assertEquals("", returnedArguments["keyTwo"]);
}
</cfscript>

</cfcomponent>