Skip to content

Commit

Permalink
fixed parser not finding trailing symbol params
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcnierney14 committed Sep 9, 2011
1 parent 8cd54fa commit e736a85
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
6 changes: 0 additions & 6 deletions README.markdown
Expand Up @@ -61,12 +61,6 @@ API Sandbox recognizes URL parameters in three forms: `:symbols`, `?first_param=

This would result in a form with four fields, one for `model`, one for `term`, one for `results_per_page`, and one for `page`.

Important note: if the API path ends with a symbol, it must end with a trailing forward slash (/) to properly parse the path. For example:

$("#user").sandbox_for("post","/api/v1/:user/:action/")

If the path had been written as `/api/v1/:user/:action`, API Sandbox would not have recognized the second field.

API Sandbox can be used to easily place interactive sandboxes inline with documentation. See [this blog post](http://mattmcnierney.wordpress.com/2011/08/18/embedding-api-sandboxes-in-documentation/) for information on how to integrate Markdown, Redcarpet 2.0.0, and API Sandbox together to create dynamic docs.

Inspiration
Expand Down
2 changes: 1 addition & 1 deletion coffeescripts/jquery.apiSandbox.coffee
@@ -1,7 +1,7 @@
(($) ->
$.fn.sandbox_for = (method,path) ->
# Get symbol params and their respective indexes in the path
symbols = if match = path.match(new RegExp(/:.+?(?=\/)/g)) then match else []
symbols = if match = path.match(new RegExp(/:.+?(?=\/)|:.+?$/g)) then match else []

# Get an array of params with jQuery bbq
params = if path.indexOf("?") > -1 then $.deparam.querystring(path) else []
Expand Down

0 comments on commit e736a85

Please sign in to comment.