Feature Request: URL Construction Utility with Dynamic Path and Query Parameters
- Dominant language
- TypeScript
- Stars
- 3.6k
- Forks
- 681
- PR merge metrics
- No merged PRs in 30d
Description
**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:
```js
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:
```js
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.
Contributor guide
Assessment
This issue has not been assessed yet.