lib/routes.js.coffee in js-routes-1.4.7 vs lib/routes.js.coffee in js-routes-1.4.8
- old
+ new
@@ -256,12 +256,10 @@
#
# This method convert value for globbing in right value for rails route
#
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?
value = switch @get_object_type(value)
when "array"
@@ -375,11 +373,11 @@
result = -1
(result = i for el, i in array when el is element)
result
namespace: (root, namespace, routes) ->
- parts = namespace.split(".")
+ parts = if namespace then namespace.split(".") else []
return routes if parts.length == 0
for part, index in parts
if index < parts.length - 1
root = (root[part] or= {})
else
@@ -400,14 +398,14 @@
throw new Error("#{NAMESPACE}.defaults is removed. Use #{NAMESPACE}.configure() instead.")
set: (value) ->
routes.default_serializer = (object, prefix) ->
Utils.default_serializer(object, prefix)
+ # Browser globals
Utils.namespace(root, NAMESPACE, routes)
# Set up Routes appropriately for the environment.
if typeof define is "function" and define.amd
# AMD
define [], -> Utils.make()
else
- # Browser globals
- Utils.make()
+ return Utils.make()