sandulat / routes-gen

Framework agnostic routes typings generator. Remix ☑️ SolidStart ☑️
MIT License
283 stars 12 forks source link

Routes with file extensions stopped working after 0.6.1 #45

Open eivindgi opened 4 months ago

eivindgi commented 4 months ago

Describe the bug

Routes with file extensions are not being handled correctly. Currently, when using the route function with a path that includes a file extension, such as /:id.pdf, and providing an id parameter, the resulting path remains unchanged.

Your Example Website or App

https://stackblitz.com/edit/node-yxbgqj?file=package.json,app%2Froutes%2F%24id[.pdf].ts

Steps to Reproduce the Bug or Issue

On the stackblitz example

  1. run npm install && npm run routes-gen && npm run dev
  2. Click on any of the two generated pdf links on the index page ("Download Foo as a pdf")
  3. You will get an 404

I have created a route called $id[.pdf].tsx (intended to be a resource route for downloading pdfs) route('/:id.pdf', {id: 'foo'}) passes type checks but the resulting path is wrong (:id.pdf)

Expected behavior

The :id placeholder in the path should be replaced with the provided id parameter, resulting in a path like /foo.pdf.

Screenshots or Videos

No response

Platform

Additional context

This naming convention with file extension is suggested by remix here: https://remix.run/docs/en/main/guides/resource-routes