lib/routes.js.coffee in js-routes-1.1.1 vs lib/routes.js.coffee in js-routes-1.1.2

- old
+ new

@@ -24,13 +24,17 @@ switch @get_object_type(object) when "array" for element, i in object s.push @default_serializer(element, prefix + "[]") when "object" - for own key, prop of object when prop? - key = "#{prefix}[#{key}]" if prefix? - s.push @default_serializer(prop, key) + for own key, prop of object + if !prop? and prefix? + prop = "" + + if prop? + key = "#{prefix}[#{key}]" if prefix? + s.push @default_serializer(prop, key) else if object? s.push "#{encodeURIComponent(prefix.toString())}=#{encodeURIComponent(object.toString())}" return "" unless s.length @@ -153,10 +157,11 @@ when NodeTypes.LITERAL, NodeTypes.SLASH, NodeTypes.DOT left when NodeTypes.CAT left_part = @visit(left, parameters, optional) right_part = @visit(right, parameters, optional) - return "" if optional and not (left_part and right_part) + return "" if optional and (((left[0] == NodeTypes.SYMBOL or left[0] == NodeTypes.CAT) and not left_part) or + ((right[0] == NodeTypes.SYMBOL or right[0] == NodeTypes.CAT) and not right_part)) "#{left_part}#{right_part}" when NodeTypes.SYMBOL value = parameters[left] if value? delete parameters[left]