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

Feature Request: URL Construction Utility with Dynamic Path and Query Parameters #6112

Open
nestarz opened this issue Oct 12, 2024 · 0 comments

Comments

@nestarz
Copy link

nestarz commented Oct 12, 2024

Is your feature request related to a problem? Please describe.

Currently, there is no utility in the jsr:@std repo that simplifies the construction of URLs with dynamic path parameters and query strings. For example, something that can easily handle creating URLs like:

urlcat("/path/:id", { id: 1, limit: 10 }); // Output: /path/1?limit=10

Additionally, there's no convenient way to update searchParams for a URL dynamically, which is something I'd like to handle more efficiently.

Describe the solution you'd like

I'd like to have a utility similar to urlcat that:

  • Allows for constructing URLs with dynamic path parameters and query strings.
  • Supports easy alteration of searchParams on demand. For example:
urlcat(new URL(request.url), { offset: 10, limit: 10 });

Where if request.url is /path/1?offset=0&limit=10, it will update the searchParams to output:

/path/1?offset=10&limit=10

Describe alternatives you've considered

  1. Using existing packages like urlcat, but integrating a more native solution into the repo would streamline and reduce dependencies.
  2. Manually updating searchParams, though this can get verbose and repetitive for common use cases.
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

No branches or pull requests

1 participant