   directory."
   [js]
   (if-let [url ^URL (-url js)]
-    (last (string/split (.getFile url) #"\.jar!/"))
+    (path-from-jarfile url)
     (str (random-string 5) ".js")))
 
 (defn write-javascript

        :when (.endsWith file ".js")]
    file))

(defn all-cljs-js
  "Return the list of all ClojureScript JavaScript files. First try to
  get them from a directory on the classpath. Then, and only then,
  look in jar files."
  []
  (letfn [(compiled-cljs? [d f] (and (.startsWith f (str (.getPath d) File/separator cljs-classpath-root))
                                      (.endsWith f ".js")))
          (remove-dot-prefix [s] (if (.startsWith s (str "." File/separator))
                                   (.substring s (count (str "." File/separator)))
                                   s))]
    (let [compiled-cljs (for [dir (remove jar-file? (classpath))
                              path (map #(.getPath %) (file-seq dir))
                              :when (compiled-cljs? dir path)]
                          (remove-dot-prefix path))]
      (if (seq compiled-cljs)
        compiled-cljs
        (for [j (classpath-jarfiles) f (filenames-in-jar j) :when (.startsWith f cljs-classpath-root)] f)))))

(defn dependency-index*
  "Create an index of dependencies by namespace and file name."
  []

                          line-seq
                          parse-js-ns
                          (assoc :file res)))]
    (let [all-nodes (map graph-node (all-goog-js))]
      (build-index all-nodes))))

(def dependency-index (memoize dependency-index*))
