Permalink
Browse files

Fix compojure.http.middleware/extension to correctly handle filenames…

… containing multiple periods.
  • Loading branch information...
1 parent 1c11486 commit 40083894d100d89347dad9748110fe06b9aab323 @arohner arohner committed with Mar 1, 2010
Showing with 3 additions and 2 deletions.
  1. +1 −1 src/compojure/http/middleware.clj
  2. +2 −1 test/compojure/http/middleware_test.clj
View
2 src/compojure/http/middleware.clj
@@ -106,7 +106,7 @@
(defn- extension
"Returns the text after the last . of a String or nil."
[s]
- (second (re-find #"\.(.*$)" s)))
+ (last (re-split #"\." s)))
(defn- request-mimetype
"Derives the mimetype from a request. See with-mimetypes for options."
View
3 test/compojure/http/middleware_test.clj
@@ -100,7 +100,8 @@
"/" "text/html"
"/foobar" "text/html"
"/file.pdf" "application/pdf"
- "/files/bar.css" "text/css"))
+ "/files/bar.css" "text/css"
+ "/files/js/jquery.fancybox-1.3.0.js" "text/javascript"))
(deftest test-with-custom-mimetypes
(let [options {:mimetypes {"foo" "test/foo"

0 comments on commit 4008389

Please sign in to comment.