     @init = (rootPath) =>
       @options = $.extend {}, $.pseudositer.defaultOptions, options
 
-      # the root
-      @rootPath = rootPath
+      # Assign the root, ensure that it ends in '/'
+      @rootPath = if rootPath.charAt( rootPath.length - 1 ) is '/' then rootPath else "#{rootPath}/"
 
       # Create loading div if one doesn't already exist,
       # and keep reference to the div.

    # Will check the cache to see if this state has been loaded before.
    #
    # @param state the State object to use when updating the view.
    # Will get the current state using History.getState() if not defined.
    #
    # @return this
    updateView = (state) =>

      showLoading()

      History.replaceState(state)

      # if we've visited the state before and grabbed data, reuse that object
      if state.url in cachedStates
        state = cachedStates[ state.url ]

      # store new state in cache if it has pseudositer data.
      else
        if state.data.pseudositer?
          cachedStates[ state.url ] = state

      # if we already have content data for state, use it
      if state.data.pseudositer?
        showLinks getPathArray state.url

        showContent state.data.pseudositer.$content

        hideLoading()

      else # load the data for the state
        # call back updateView after the state is loaded
        createStateObjectWithData state.title, state.url, updateView

      this

    # Asynchronously create a new state object with freshly loaded data.
    #
    # This load new view data from the provided url.  If the state is an index,
    # make ajax requests to unfold it to the deepest directory and the
    # first object in that directory.
    #
    # @param deferred
    # @param title the title of the new state object
    # @param url the url of the new state object
    #
    # @return this
    createStateObjectWithData = (deferred, title, url) =>

      data = {}

      componentPaths = componentPaths sansData.url



      withData = History.createStateObject data sansData.title sansData.url

      this

    # Load a new set of links into @pathLinks.
    #
    # @param deferred the deferred to append this asynchronous operation to.
    # @param path the path to the links to load.
    #
    # @return this
    loadLinks = (deferred, path) =>

      deferred.then =>
        ajaxGet path, (data, textStatus, jqXHR) =>
          @pathLinks[ path ] = $(data).find(options.linkSelector)

      this

    # Load generic content from a path into an object.
    #
    # @param deferred the deferred to append this asynchronous operation to.
    # @param path the path to the links to the content to load.
    # @param object
    #
    # @return this
    loadContent = (deferred, path, object) =>

      deferred.then =>
        switch getSuffix path
          when 'jpg' then
            loadImage deferred, path, object
          when 'gif' then
            loadImage deferred, path, object
          when 'png' then
            loadImage deferred, path, object
          when 'txt' then
            loadText deferred, path, object
          when 'html' then
            loadText deferred, path, object
          else
            loadText deferred, path, object

      this

    loadImage = (path, object) =>
      object.content = $( 'img' ).attr 'src', absPath(path)

    loadText = (deferred, path, object) =>

    # Show the links for a path, in addition to the links for all its
    # parents.  This data should already have been loaded into
    # @pathLinks .
    #
    # @param path the path
    #
    # @return this
    showLinks = (path) =>

      trail = getTrail(path)

      for pathNum in [0...trail.length]
        path = trail[pathNum]
        $links = @pathLinks[path]

      this


    # @param $content the DOM content to display.
    #
    # @return this
    showContent = ( $content ) =>
      $( @$content ).empty ()
        .append( $content );
      this

    # call init, and return the output
    @init()

  # object literal containing default options
  $.pseudositer.defaultOptions =
    loadingClass   : 'pseudositer-load'
    contentClass   : 'pseudositer-content'
    staleClass     : 'pseudositer-stale'
    linkClass      : 'pseudositer-links'
  	linkSelector   : 'a:not([href^="?"],[href^="/"])', # Find links from a directory listing that go deeper


  $.fn.pseudositer = (options) ->
    $.each @, (i, el) ->
