Skip to content

[fix] 1714 rest params in endpoint #2955

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

Closed

Conversation

dreitzner
Copy link
Contributor

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Dec 1, 2021

🦋 Changeset detected

Latest commit: fae0950

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

if (/.+\[\.\.\.[^\]]+\]/.test(segment) || /\[\.\.\.[^\]]+\].+/.test(segment)) {
if (
/.+\[\.\.\.[^\]]+\]/.test(segment) ||
(/\[\.\.\.[^\]]+\].+/.test(segment) && !/\[\.\.\.[^\]]+\]\.json$/.test(segment))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt we want a hard-coded check for [...rest].json.js. .json is a convention and it can be anything else by the user. Also, have you confirm with this change that a SvelteKit app still routes normally? I have a hunch there are other places to fix as well.

With that said, I'm not sure what's the path forward, or maybe we should stick with the issue workaround for now. I'll see if the others has an opinion on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to make it more flexible in the future.

But there are strong reasons to implement that fix:

  • .json is the framework convention for endpoints
  • .json is used in the example project
  • because of that we would create unnecessary friction for new users coming to the framework

@dreitzner dreitzner changed the title 1714 rest params in endpoint [fix] 1714 rest params in endpoint Dec 6, 2021
@Rich-Harris
Copy link
Member

Thank you. The answer is both simpler and more complicated than this — simpler in that we can just allow any rest segment to have a prefix/suffix (as I believe was the case with Sapper), and more complex in that we need to tweak the implementation a bit. Closing this in favour of #3240.

@Rich-Harris Rich-Harris closed this Jan 7, 2022
@dreitzner dreitzner deleted the 1714-rest-params-in-endpoint branch November 14, 2022 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow rest parameters as end of endpoint route
3 participants