lib/routes.js.coffee in js-routes-1.4.4 vs lib/routes.js.coffee in js-routes-1.4.5

- old
+ new

@@ -1,10 +1,9 @@ ### File generated by js-routes GEM_VERSION -Based on Rails routes of APP_CLASS +Based on Rails RAILS_VERSION routes of APP_CLASS ### -# root is this root = (exports ? this) ParameterMissing = (message, fileName, lineNumber) -> instance = new Error(message, fileName, lineNumber) if Object.setPrototypeOf @@ -26,12 +25,12 @@ Object.setPrototypeOf(ParameterMissing, Error) else ParameterMissing.__proto__ = Error NodeTypes = NODE_TYPES +DeprecatedGlobbingBehavior = DEPRECATED_GLOBBING_BEHAVIOR SpecialOptionsKey = SPECIAL_OPTIONS_KEY -DeprecatedBehavior = DEPRECATED_BEHAVIOR ReservedOptions = [ 'anchor' 'trailing_slash' 'subdomain' @@ -133,11 +132,11 @@ options = @extract_options(parts.length, actual_parameters) if actual_parameters.length > parts.length throw new Error("Too many parameters provided for path") - use_all_parts = DeprecatedBehavior or actual_parameters.length > required_parts.length + use_all_parts = actual_parameters.length > required_parts.length parts_options = {} for own key of options use_all_parts = true if @indexOf(parts, key) >= 0 @@ -209,13 +208,13 @@ ((@is_optional_node(right[0])) and not right_part)) return "" "#{left_part}#{right_part}" when NodeTypes.SYMBOL value = parameters[left] + delete parameters[left] if value? - delete parameters[left] - return @path_identifier(value) + return encodeURIComponent(@path_identifier(value)) if optional "" # missing parameter else throw new ParameterMissing("Route parameter missing: #{left}") # @@ -258,16 +257,21 @@ visit_globbing: (route, parameters, optional) -> [type, left, right] = route # fix for rails 4 globbing route[1] = left = left.replace(/^\*/i, "") if left.replace(/^\*/i, "") isnt left value = parameters[left] + delete parameters[left] return @visit(route, parameters, optional) unless value? - parameters[left] = switch @get_object_type(value) + value = switch @get_object_type(value) when "array" value.join("/") else value - @visit route, parameters, optional + + if DeprecatedGlobbingBehavior + @path_identifier(value) + else + encodeURI(@path_identifier(value)) # # This method check and return prefix from options # get_prefix: ->