Permalink
Browse files

Convert group name to path

Group names with . in them are stored in subdirectories in a maven-style
repo. Fixes #650.
  • Loading branch information...
1 parent 4a4523c commit 15603d528cf63872d9f2052502800c653e279f2b @tobias tobias committed Jul 23, 2017
Showing with 12 additions and 1 deletion.
  1. +2 −1 src/clojars/web/jar.clj
  2. +10 −0 test/clojars/test/unit/web/jar.clj
View
@@ -10,6 +10,7 @@
[clojars.db :refer [find-jar jar-exists]]
[clojars.stats :as stats]
[clojars.config :refer [config]]
+ [clojars.file-utils :as fu]
[ring.util.codec :refer [url-encode]]
[cheshire.core :as json]
[clojars.web.helpers :as helpers]
@@ -21,7 +22,7 @@
(str (jar-url jar) "/versions/" (:version jar)))
(defn repo-url [jar]
- (str (:cdn-url @config) "/" (:group_name jar) "/" (:jar_name jar) "/"))
+ (str (:cdn-url @config) "/" (-> jar :group_name fu/group->path) "/" (:jar_name jar) "/"))
(defn maven-jar-url [jar]
(str "http://search.maven.org/#"
@@ -34,3 +34,13 @@
[]
0)]
(is (not (.contains html "<script>alert('hi')</script>")))))
+
+(deftest groups-are-converted-to-paths
+ (let [html (jar/show-versions nil
+ {:homepage "whatever"
+ :created 3
+ :version "1"
+ :group_name "test.foo"
+ :jar_name "test"}
+ ["1"])]
+ (is (re-find #"/test/foo/test" html))))

0 comments on commit 15603d5

Please sign in to comment.