Skip to content

Conversation

@ak4zh
Copy link

@ak4zh ak4zh commented Sep 19, 2025

Fixes #179 and also the types as discussed here #177 (comment)

This is a draft / proof-of-concept for a potential new feature in queryParameters:

  1. $parsed helper – returns a plain object containing only the keys defined in the query parameters.
    Unlike toJSON, it ignores extra URL params like UTM tags or tracking parameters.
    Provides a clean, whitelist-based snapshot of the parameters you explicitly defined.

  2. toJSON typing fix – updated the return type of toJSON to correctly reflect the decoded shape of the defined query parameters.

We can have something like $parseDefined(), $parseAll() etc

Notes:

This PR is just an idea and meant to start discussion.

Open for feedback on:

  • The name $parsed
  • Implementation details and typing
  • Any alternative approaches

@changeset-bot
Copy link

changeset-bot bot commented Sep 19, 2025

⚠️ No Changeset found

Latest commit: 31bbfaf

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

@ak4zh
Copy link
Author

ak4zh commented Sep 20, 2025

After testing some ideas may be the library can make use of the reactive SvelteURLSearchParams.
I have been playing around with it and have setup this playground https://www.sveltelab.dev/z803hig0aebr4qq

I don't know how to get it to work for nested data but I don't even care about nested data if arrays can be handled correctly that's enough for most use cases. Also struggling with typescript a lot but it seems to work.

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.

Feature Request: Option to Filter queryParameters against a defined schema

1 participant