Question

I'm trying to create a route that has a parameter which contains commas in compojure

(GET "/tags/multiple/:tag-names" [tag-names] multiple-tags)

but for some reason, whenever I include a comma in the :tag-names field, it 404s. It works fine when there are no commas.

Does anyone know what causes this and how I can work around it?

Was it helpful?

Solution

Compojure uses clout for routing. From clout's README:

Clout supports both keywords and wildcards. Keywords (like :title) will match any character but the following: / . , ; ?.

By default, clout treats commas as path segment separators. You can work around that by passing a custom regex to the route. The following would make :tag-names match any character except /:

(GET ["/tags/multiple/:tag-names" :tag-names #"[^/]+"] [tag-names] multiple-tags)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top