Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support routes with mixed slug and static params in same segment #2001

Open
Atinux opened this issue Dec 12, 2023 — with Volta.net · 1 comment
Open

Support routes with mixed slug and static params in same segment #2001

Atinux opened this issue Dec 12, 2023 — with Volta.net · 1 comment
Labels

Comments

Copy link
Member

Atinux commented Dec 12, 2023

I believe this is a bug:

routes/[slug].txt.ts:

export default eventHandler(async (event) => {
  return event.context.params;
});

Response when hitting http://localhost:3000/test.txt

{
  "slug.txt": "test.txt"
}

Reproduction: https://stackblitz.com/edit/github-kx4iv8?file=routes%2Findex.ts,routes%2F%5Bslug%5D.txt.ts

@Atinux Atinux added bug Something isn't working workaround available labels Dec 12, 2023 — with Volta.net
Copy link
Member Author

Atinux commented Dec 12, 2023

Current workaround:

const slug = event.context.params.slug || (event.context.params['slug.txt'] || '').replace('.txt', '')

Waiting for unjs/radix3#52 to be added to Nitro

@pi0 pi0 changed the title Route with params & extension include extension Support routes with mixed slug and static params in same segment Dec 12, 2023
@pi0 pi0 added enhancement New feature or request and removed bug Something isn't working labels Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants