Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Assets are distinct based on :path and :bundle

Fixes #10
  • Loading branch information...
commit 9642aafcb5cd2b87e51f79aea242afc73e1b77d4 1 parent 699b8c5
@magnars authored
Showing with 13 additions and 3 deletions.
  1. +3 −3 src/optimus/strategies.clj
  2. +10 −0 test/optimus/strategies_test.clj
View
6 src/optimus/strategies.clj
@@ -19,11 +19,11 @@
asset-1)
(defn- guard-against-duplicate-assets [assets]
- (let [path->assets (group-by :path assets)]
+ (let [pb->assets (group-by (juxt :path :bundle) assets)]
(->> assets
- (map :path)
+ (map (juxt :path :bundle))
(distinct)
- (map path->assets)
+ (map pb->assets)
(map #(reduce collapse-equal-assets %)))))
(defn serve-live-assets [app get-assets optimize options]
View
10 test/optimus/strategies_test.clj
@@ -89,6 +89,16 @@
(app {}) => {:optimus-assets [{:path "/code.js" :contents "abc"}]}))
(fact
+ "Assets are allowed to be duplicated if they belong to different bundles."
+
+ (defn get-assets [] [{:path "/code.js" :contents "abc" :bundle "app1.js"}
+ {:path "/code.js" :contents "abc" :bundle "app2.js"}])
+
+ (let [app (serve-live-assets return-request get-assets dont-optimize {})]
+ (app {}) => {:optimus-assets [{:path "/code.js" :contents "abc" :bundle "app1.js"}
+ {:path "/code.js" :contents "abc" :bundle "app2.js"}]}))
+
+(fact
"Duplicate assets that are not equal are not tolerated."
(defn get-assets [] [{:path "/code.js" :contents "abc"}
Please sign in to comment.
Something went wrong with that request. Please try again.