From e736a852cbabc6da3e61eb659b425f3f986096e3 Mon Sep 17 00:00:00 2001 From: Matthew McNierney Date: Fri, 9 Sep 2011 14:47:24 -0400 Subject: [PATCH] fixed parser not finding trailing symbol params --- README.markdown | 6 ------ coffeescripts/jquery.apiSandbox.coffee | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/README.markdown b/README.markdown index 568c449..7a3ab16 100644 --- a/README.markdown +++ b/README.markdown @@ -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 diff --git a/coffeescripts/jquery.apiSandbox.coffee b/coffeescripts/jquery.apiSandbox.coffee index 99c71d0..cdc61f4 100644 --- a/coffeescripts/jquery.apiSandbox.coffee +++ b/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 []