Permalink
Browse files

Fixed a small issue where there's no params the form submission would…

… fail silently
  • Loading branch information...
1 parent 256101d commit 6b05692fa5ef90f9978f1838b323a02f4572a596 @fredwu committed Nov 28, 2012
Showing with 11 additions and 8 deletions.
  1. +11 −8 app/assets/javascripts/api_taster/app.js
View
19 app/assets/javascripts/api_taster/app.js
@@ -39,18 +39,21 @@ var ApiTaster = {
var baseUrl = $form.attr('action');
var matches = baseUrl.match(/\:[^\/]+/g)
- for(var a = 0; a < matches.length; a++) {
- var match = matches[a];
- var str = match.substr(1);
+ if (matches) {
+ for(var a = 0; a < matches.length; a++) {
+ var match = matches[a];
+ var str = match.substr(1);
- var $input = $form.find(
- 'input[name="' + str + '"],input[name="[api_taster_url_params]' + str + '"]'
- );
+ var $input = $form.find(
+ 'input[name="' + str + '"],input[name="[api_taster_url_params]' + str + '"]'
+ );
- if($input.length > 0) {
- baseUrl = baseUrl.replace(match, $input.val());
+ if ($input.length > 0) {
+ baseUrl = baseUrl.replace(match, $input.val());
+ }
}
}
+
return baseUrl;
}

0 comments on commit 6b05692

Please sign in to comment.