juxt / bidi

Bidirectional URI routing
MIT License
993 stars 90 forks source link

Resources not matching wildcard #173

Open theronic opened 6 years ago

theronic commented 6 years ago

The example given in README for bidi-ring/->ResourceMaybe does not seem to match any subpath as explained, e.g.:

(def routes
  ["/" {""   :home
        "js" #?(:clj  (bidi-ring/->ResourcesMaybe {:prefix "js/"})
                :cljs :server-fetch)
        true :not-found}])
(bidi/match-route* routes/routes "/js" {})
=>
{:handler #object[bidi.ring$eval22229$__GT_ResourcesMaybe__22247
                  0x22dbf7fe
                  "bidi.ring$eval22229$__GT_ResourcesMaybe__22247@22dbf7fe"]}

(bidi/match-route* routes/routes "/js/anything-else" {})
=> {:handler :not-found}

I'm guessing I need to specify "js/.*"?

theronic commented 6 years ago

I tried ["/js" :path] and ["/js/.*] with no luck.

Using bidi v2.1.2, the following route does not match:

(let [routes ["" [["/" :index]]
              ["/css/" (bidi-ring/->ResourcesMaybe {:prefix "public/css/"})]
              ["/js/" (bidi-ring/->ResourcesMaybe {:prefix "public/js/"})]]]
  (bidi/match-route routes "/js/anything.js"))
=> nil
amitvshah25 commented 5 years ago

I am struggling with the same issue. Were you able to figure this out ?