 # Possibly modifies the current browser URL to the to provided path, based on
 # the behavior requested in the 'urlBehavior' parameter (a
 # noughts.state.UrlBehavior).
-noughts.state.updateUrl = (path, urlBehavior) ->
+noughts.state.updateUrl = (urlBehavior, path) ->
   # TODO(dthurn): No point in doing this if we're inside the Facebook iframe
-  displayError("Invalid path: #{path}!") unless path?
   if urlBehavior == noughts.state.UrlBehavior.PUSH_URL
     window.history.pushState({}, "", path)
   else if urlBehavior == noughts.state.UrlBehavior.REPLACE_URL

    noughts.state.changeState(noughts.state.FACEBOOK_INVITE,
        noughts.state.UrlBehavior.PRESERVE_URL)
  else if path == ""
    # The path is the string "null" when inside the Facebook iFrame
    games = noughts.Games.find({}, {sort: {lastModified: -1}}).fetch()
    myTurnGames = _.filter(games, myTurn)
    if myTurnGames.length > 0

  urlBehavior ||= noughts.state.UrlBehavior.PUSH_URL
  Session.set("state", newState)
  newScreen = noughts.state.stateMap[newState]
  # Arguments should be [urlBehavior, args[2], args[3], etc]
  newArgs = [urlBehavior].concat(_.toArray(arguments).slice(2))
  newScreen.enterState.apply(newScreen, newArgs)

# What a new state should do to the browser URL when entered.
noughts.state.UrlBehavior =
