       path = resolve '/', file.relative
         .replace /index\.[^/]+$/, ''          # index identified with directory
         .replace /\.[^./]+$/, '.' + hrefExtension     # e.g. '.jade' -> '.html'
-        .split /([^/]*\/)/                    # e.g. '/a/b' -> ['/', 'a/', 'b']
-        .filter (element) -> element isnt ''
       # find the right spot for the new resource
       current = navTree
-      for element in path
+      for element in (path.split /([^/]*\/)/  # e.g. '/a/b' -> ['/', 'a/', 'b']
+          .filter (element) -> element isnt '')
         current = current.children[element] ?= # recurse down the path, filling
           parent: current                      # in tree with missing elements
           children: {}

      current.title = title ? current.title # overwrite defaults with non-nulls
      current.order = order ? current.order
      # use leaf to make the nav object
      nav = navInContext current, [path.join '']
      # set properties of vinyl object XXX does this need error handling?
      for target in targets
        obj = file

through = require 'through2'
{relative, resolve} = require './web-path'

# XXX could these be somewhere else?
root = rootName = null

module.exports = ({sources, targets, titles, orders, skips, hrefExtension,
