cljdoc / cljdoc

📚 A central documentation hub for the Clojure community
https://cljdoc.org
Eclipse Public License 2.0
538 stars 79 forks source link

Ensure that /badge endpoint will 404 with more than one slash in project ID #348

Closed nha closed 5 years ago

nha commented 5 years ago

My library is there: https://cljdoc.org/d/com.turtlequeue/clj-client/0.0.7 It seems I should be able to get a badge https://cljdoc.org/badge/com.turtlequeue/clj-client/0.0.7

NOTE: there is no SCM configured - I am assuming this may be the cause here

Also I noticed it does not appear in the search but it may be unrelated ( https://github.com/cljdoc/cljdoc/issues/308#issuecomment-530584697 )

martinklepsch commented 5 years ago

Hey Nicolas! I didn't realize on Slack; the issue is simply that there shouldn't be a version at the end of the badge URL. Instead the badge will always display the most recent version:

https://cljdoc.org/badge/com.turtlequeue/clj-client

martinklepsch commented 5 years ago

We should probably update the routing table to ensure that the URL you used results in a 404. Will reopen and rename this issue to track that. Thanks for prompting this 🙂

martinklepsch commented 5 years ago

Probably we should split up the route here to not use a catch-all parameter:

https://github.com/cljdoc/cljdoc/blob/1eaaac904b275ebe581f1775a3c4b5bb44e43bdd/src/cljdoc/server/routes.clj#L55-L57

["/badge/project-id" :get nop :route-name :badge-for-project]
["/badge/group-id/artifact-id" :get nop :route-name :badge-for-project]

And then the handler for that route should intelligently determine group and artifact ID based on these params. If project-id is provided we will assume group and artifact ID are identical.