How to have "-" after parameter in plug route

If I have a route that receives a named parameter :thing and also has some extra suffix text immediately after the named parameter:

get "/:thing-extra-suffix-text" do

I get the error:

(Plug.Router.InvalidSpecError) :identifier in routes must be made of letters, numbers and underscores

How can I specify a plug that has such a route?

This is a common requirement for SEO considerations. E.g., for a job site one may have routes of the form /:city-jobs where only the city varies but never the suffix.

Looks like this is not currently possible. There is an open PR from a while ago that implements having a static suffix here:

1 Like