-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Description
Suppose you have an API with ONLY the following URI implemented: /api/v1/index.cfm/pizza/{topping}
- If a request arrives for
/api/v1/index.cfm/pizzawe currently return a 404. This is good. 👍🏻 - If a request arrives for
/api/v1/index.cfm/pizza/we currently throw an exception. This is bad. 👎🏻
The problem is that an empty-string is an acceptable match for tokens. This behavior should continue. There are valid reasons to expect and allow empty-string as a token value.
However, in this case, when buildRequestArguments executes, it doesn't account for this possibility. We would expect a response in the shape of { topping: "" }. Instead an error is thrown while trying to reference the token here (line 1015).
Lines 1009 to 1017 in ce987af
| <!--- parse path_info data into key-value pairs ---> | |
| <cfset local.tokenValues = reFindNoSuck(arguments.regex, arguments.uri) /> | |
| <cfset local.numTokenValues = arrayLen(local.tokenValues) /> | |
| <cfset local.numTokenNames = arrayLen(arguments.tokenNamesArray) /> | |
| <cfif local.numTokenNames gt 0> | |
| <cfloop from="1" to="#local.numTokenNames#" index="local.t"> | |
| <cfset local.returnData[arguments.tokenNamesArray[local.t]] = local.tokenValues[local.t] /> | |
| </cfloop> | |
| </cfif> |