Skip to content

Feature Request: Option to Filter queryParameters against a defined schema #179

@ak4zh

Description

@ak4zh

Describe the problem

Summary

I am using queryParameters as a way to search and filter data on my website. However, sometimes additional parameters (like UTM tags or other tracking query params) get added to the URL. Currently, these extra params are also parsed, which makes it harder to work only with the parameters I’ve defined.

Problem

I want to be able to parse the query string and only extract the keys/values that I’ve explicitly set in queryParameters. At the moment, there’s no built-in way to ignore unknown parameters.

Describe the proposed solution

Introduce an option (or utility) that:

  • Parses the query string.
  • Returns only the keys that match those defined in queryParameters.
  • Outputs a clean JSON object with just the relevant values.

Example

// Suppose I define:
const params = queryParameters({
  q: ssp.string(),
  page: ssp.number(),
});
let parsed = $derived(params.$parsed)

// URL contains:
?q=svelte&page=2&utm_source=google

// Desired result of parsed:
{ q: "svelte", page: 2 }

Benefits

  • Cleaner query parsing.
  • Prevents noise from unrelated query parameters (UTM, tracking, etc.).
  • Makes filtering and searching more predictable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions