Skip to content

Commit

Permalink
Merge pull request atuttle#282 from jbvanzuylen/support_array_in_quer…
Browse files Browse the repository at this point in the history
…y_string

Added support for arrays in query string
  • Loading branch information
Adam Tuttle committed Jul 16, 2015
2 parents 1e83bfe + 376ca1d commit 7aba85e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions core/api.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,19 @@
</cfif>
<!--- query_string input is also key-value pairs --->
<cfloop list="#arguments.queryString#" delimiters="&" index="local.t">
<cfset local.qsKey = urlDecode(listFirst(local.t,'=')) />
<cfset local.qsValue = "" />
<cfif listLen(local.t,'=') eq 2>
<cfset local.returnData[listFirst(local.t,'=')] = urlDecode(listLast(local.t,'=')) />
<cfset local.qsValue = urlDecode(listLast(local.t,'=')) />
</cfif>
<cfif (len(local.qsKey) gt 2) and (right(local.qsKey, 2) eq "[]")>
<cfset local.qsKey = left(local.qsKey, len(local.qsKey) - 2) />
<cfif not structKeyExists(local.returnData, local.qsKey)>
<cfset local.returnData[local.qsKey] = arrayNew(1) />
</cfif>
<cfset arrayAppend(local.returnData[local.qsKey], local.qsValue) />
<cfelse>
<cfset local.returnData[listFirst(local.t,'=')] = "" />
<cfset local.returnData[local.qsKey] = local.qsValue />
</cfif>
</cfloop>
<!--- if a mime type is requested as part of the url ("whatever.json"), then extract that so taffy can use it --->
Expand Down
4 changes: 2 additions & 2 deletions dashboard/dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ $(function(){
delete tokens[t];
}
var result = uri.supplant(tokens);
result += (q.length) ? '?' + q : '';
result += (q.length) ? '?' + decodeURIComponent(q) : '';
resource.find('.resourceUri').val(result);
});

Expand Down Expand Up @@ -99,7 +99,7 @@ $(function(){
,path = uri.supplant(form);

var verb = resource.find('.reqMethod option:checked').val();
var body = (verb === 'GET' || verb === 'DELETE') ? params(qParams(resource)) : resource.find('.reqBody textarea').val();
var body = (verb === 'GET' || verb === 'DELETE') ? qParams(resource) : resource.find('.reqBody textarea').val();
var reqHeaders = resource.find('.requestHeaders').val().replace(/\r/g, '').split('\n');
var headers = {
Accept: resource.find('.reqFormat option:checked').val()
Expand Down

0 comments on commit 7aba85e

Please sign in to comment.