Skip to content

Support suffixes for [...rest] endpoints #4656

Closed
@ngalaiko

Description

@ngalaiko

Describe the problem

I have a project with a following pages routes structure:

/routes/index.svelte
/routes/posts/index.svelte
/routes/posts/index.json.js
/routes/posts/category1/index.svelte
/routes/posts/category2/index.svelte
/routes/posts/[...catchall]/index.json.js
/routes/posts/[...catchall]/index.svelte

What I am doing there:

  • /routes/posts/index.{svelte,json.js} is a list page with every post
  • /routes/posts/category*/**/*.svelte are posts with just markup and some props
  • /routes/posts/[...catchall]/index.svelte fires when no post if found, so it queries /routes/posts/[...catchall]/index.json.js to check if the post has an alias and redirects

What I would like to do is to add a generic /likes.json endpoint to all the posts, so:

...
/routes/posts/[...catchall]/likes.json.js
/routes/posts/[...catchall]/index.svelte
/routes/posts/[...catchall]/index.svelte

But the problem I am facing is that the request is routed to the /routes/posts/[...catchall]/index.svelte handler, even though according to sorting rules, likes.json must have a priority

Describe the proposed solution

Support catchall suffixes

Alternatives considered

I could solve this without having [...rest] matcher of course, but that involves either copy-paste, or manual routing.

Importance

would make my life easier

Additional Information

This seems like an improvement of an existing feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions