Skip to content

Conversation

@dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Dec 7, 2022

This is breaking change for people who relied on the __data.json suffix being present on event.url which is now no longer the case. Use the new isDataRequest boolean instead.

export function handle({ event, resolve }) {
-  if (event.url.pathname.endsWith('__data.json') {
+  if (event.isDataRequest) {
    // ..
  }
  return resolve(event);
}

closes #7926

Open question: Should we also remove those things from the original request object? I vote for "no".

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

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

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 pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Dec 7, 2022

🦋 Changeset detected

Latest commit: 404c39a

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

},
({ event, resolve }) => {
if (
event.request.url.includes('__data.json') &&
Copy link
Member

Choose a reason for hiding this comment

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

this would prevent contrived-but-allowed things like /__data.json/wheee, no? Don't we just want to check the end of the pathname?

Copy link
Member

Choose a reason for hiding this comment

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

This is just part of a test, not the code that users are going to run.

Copy link
Member

Choose a reason for hiding this comment

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

i definitely knew that and wasn't just being absent-minded

@Rich-Harris Rich-Harris merged commit 5f3192f into master Dec 8, 2022
@Rich-Harris Rich-Harris deleted the strip-data-json branch December 8, 2022 20:48
This was referenced Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hide /__data.json from the url object inside handle

4 participants