Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: michaelklishin/pantomime
base: 63feacdc29
head fork: michaelklishin/pantomime
compare: 03f8376bce
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
@@ -1,3 +1,12 @@
+## Changes between Pantomime 1.3.0-beta2 and 1.3.0-rc1
+### New functions in
+New functions that return media type parameters and charset:
+* ``
## Changes between Pantomime 1.3.0-beta1 and 1.3.0-beta2
### New functions in
7 src/pantomime/media.clj
@@ -40,6 +40,7 @@
(defprotocol MediaTypeOps
(base-type [input] "Returns base media type for given input, for example, text/html for text/html; charset=UTF-8")
(parameters-of [input] "Returns optional parameters map for given input")
+ (has-parameters? [input] "Returns true if given content type has parameters, false otherwise")
(charset-of [input] "Returns optional charset given input, for example, UTF-8 for text/html; charset=UTF-8 and nil for text/html")
(application? [input] "Returns true if input is an application/* media type, false otherwise")
(text? [input] "Returns true if input is a text/* media type, false otherwise")
@@ -58,6 +59,9 @@
[^String input]
(parameters-of (parse input)))
+ (has-parameters?
+ [^String input]
+ (has-parameters? (parse input)))
[^String input]
(charset-of (parse input)))
@@ -92,6 +96,9 @@
[^MediaType input]
(when-let [^Map jm (.getParameters input)]
(into {} jm)))
+ (has-parameters?
+ [^MediaType input]
+ (.hasParameters input))
[^MediaType input]
(when-let [m (parameters-of input)]
13 test/pantomime/test/media.clj → test/pantomime/test/media_test.clj
@@ -1,7 +1,7 @@
- (:use [clojure.test])
+ (:use clojure.test)
(:require [ :as media])
- (:import [org.apache.tika.mime MediaType]))
+ (:import org.apache.tika.mime.MediaType))
(deftest test-media-type-named
@@ -24,6 +24,13 @@
(is (nil? (media/charset-of "text/html")))
(is (nil? (media/charset-of "text/html; key=val"))))
+(deftest test-parameters-of
+ (let [with-params (media/parse "text/html; charset=UTF-8")
+ without-params (media/parse "text/html")]
+ (is (= {"charset" "UTF-8"} (media/parameters-of with-params)))
+ (is (media/has-parameters? with-params))
+ (is (= {} (media/parameters-of without-params)))
+ (is (not (media/has-parameters? without-params)))))
(deftest test-multipart-predicate
(are [mt] (is (media/multipart? mt))
7 test/pantomime/test/mime.clj → test/pantomime/test/mime_test.clj
@@ -1,9 +1,8 @@
-(ns pantomime.test.mime
- (:use [pantomime.mime]
- [clojure.test])
+(ns pantomime.test.mime-test
+ (:use pantomime.mime clojure.test)
(:require [ :as io])
(:import [ File FileInputStream]
- [ URL]))
(deftest test-content-type-detection

No commit comments for this range

Something went wrong with that request. Please try again.