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

replace request.origin/path/query with request.url #3126

Merged
merged 40 commits into from
Dec 30, 2021
Merged

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Dec 29, 2021

This is a substantial breaking change, but a welcome one — it simplifies things a bit. It replaces request.origin, request.path and request.query with a single request.url, which is a standard URL object.

Similarly, page load functions now take a { url, params, ... } object rather than { page, ... }, and the page store contains { url, params }.

@Conduitry suggested we take this opportunity to rethink the naming of params, though I haven't had any particularly great ideas for what to rename it to.

Closes #3078.

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

@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2021

⚠️ No Changeset found

Latest commit: 2126c04

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@Conduitry
Copy link
Member

I didn't have any great ideas of what to rename params to either, unfortunately. My concern was that, since it was no longer part of the $page store and no longer alongside other URL-y things, the name params would be a bit vague. I had half-heartedly suggested slugs but Rich wasn't any more thrilled with that one than I was.

@Rich-Harris
Copy link
Member Author

Rich-Harris commented Dec 29, 2021

Still to do:

  • fix the one remaining broken test (change detection for load functions is less granular than previously — need to either make it more granular, or change the test)
  • docs
  • add getters on the request/load arguments so that people currently using path, query and origin understand why their app broke

Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
@silentworks
Copy link

@Rich-Harris I know this is closed but am I correct in thinking the original statement of ...and the page store has been replaced with url and params stores no longer applies since it seems page store still exists in the latest version?

@Rich-Harris
Copy link
Member Author

Yep, classic case of the comments not matching the code. Last-minute bikeshedding

spences10 added a commit to spences10/scottspence.com that referenced this pull request Jan 1, 2022
breaking change in requst.origin/path/query, see sveltejs/kit#3126

all places where page is used in a load function
cedricr added a commit to gip-inclusion/dora-front that referenced this pull request Jan 3, 2022
spences10 added a commit to hygraph/hygraph-sveltekit-portfolio-and-blog-starter that referenced this pull request Jan 11, 2022
spences10 added a commit to hygraph/hygraph-examples that referenced this pull request Jan 27, 2022
giokara-oqton added a commit to giokara/telraam-bloemekeswijk that referenced this pull request Apr 18, 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.

Full Request URL Data
4 participants