Skip to content

Commit 1404485

Browse files
committed
Merge branch 'master' of github.com:clojure/clojurescript
2 parents 27ad78b + 98ed0f4 commit 1404485

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

src/main/clojure/cljs/closure.clj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,10 @@
371371
(if output-file
372372
(let [out-file (io/file (util/output-directory opts) output-file)]
373373
(compiled-file (comp/compile-file file out-file opts)))
374-
(binding [ana/*cljs-file* (.getPath ^File file)]
375-
(with-open [rdr (io/reader file)]
376-
(compile-form-seq (ana/forms-seq* rdr))))))
374+
(let [path (.getPath ^File file)]
375+
(binding [ana/*cljs-file* path]
376+
(with-open [rdr (io/reader file)]
377+
(compile-form-seq (ana/forms-seq* rdr path)))))))
377378

378379
(defn compile-dir
379380
"Recursively compile all cljs files under the given source

src/main/clojure/cljs/repl/browser.clj

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
(def ^:dynamic ordering nil)
2525
(def ^:dynamic es nil)
2626

27+
(def ext->mime-type
28+
{".html" "text/html"
29+
".css" "text/css"
30+
31+
".jpg" "image/jpeg"
32+
".png" "image/png"
33+
".gif" "image/gif"
34+
35+
".js" "text/javascript"
36+
".cljs" "text/x-clojure"
37+
".cljc" "text/x-clojure"
38+
".map" "application/json"})
39+
2740
(defn- set-return-value-fn
2841
"Save the return value function which will be called when the next
2942
return value is received."
@@ -84,16 +97,8 @@
8497
local-path)]
8598
(if local-path
8699
(server/send-and-close conn 200 (slurp local-path)
87-
(condp #(.endsWith %2 %1) path
88-
".html" "text/html"
89-
".css" "text/css"
90-
".html" "text/html"
91-
".jpg" "image/jpeg"
92-
".js" "text/javascript"
93-
".cljs" "text/x-clojure"
94-
".cljc" "text/x-clojure"
95-
".map" "application/json"
96-
".png" "image/png"
100+
(if (some #(.endsWith path %) (keys ext->mime-type))
101+
(get ext->mime-type path)
97102
"text/plain"))
98103
(server/send-404 conn path)))
99104
(server/send-404 conn path)))
@@ -105,14 +110,7 @@
105110

106111
(server/dispatch-on :get
107112
(fn [{:keys [path]} _ _]
108-
(or
109-
(= path "/")
110-
(.endsWith path ".js")
111-
(.endsWith path ".cljc")
112-
(.endsWith path ".cljs")
113-
(.endsWith path ".map")
114-
(.endsWith path ".html")
115-
(.endsWith path ".css")))
113+
(or (= path "/") (some #(.endsWith path %) (keys ext->mime-type))))
116114
send-static)
117115

118116
(defmulti handle-post (fn [m _ _ ] (:type m)))

0 commit comments

Comments
 (0)