lib/routes.js.coffee in js-routes-1.4.0 vs lib/routes.js.coffee in js-routes-1.4.1
- old
+ new
@@ -274,19 +274,21 @@
path_fn
route_url: (route_defaults) ->
return route_defaults if typeof route_defaults == 'string'
+
+ hostname = route_defaults.host || Utils.current_host()
+
+ return '' unless hostname
+
protocol = route_defaults.protocol || Utils.current_protocol()
- hostname = route_defaults.host || window.location.hostname
port = route_defaults.port || (Utils.current_port() unless route_defaults.host)
port = if port then ":#{port}" else ''
protocol + "://" + hostname + port
-
- has_location: ->
- typeof window != 'undefined' && typeof window.location != 'undefined'
+ has_location: -> window?.location?
current_host: ->
if @has_location() then window.location.hostname else null
current_protocol: () ->