{"library":"replace-url-values","title":"URL Value Replacer","description":"The `replace-url-values` package, currently at version `1.0.0`, is designed as a focused utility to programmatically substitute specified values within a given URL string. It likely facilitates the dynamic generation of URLs by replacing placeholders in path segments (e.g., `:id`) or modifying existing query parameters. While specific details about its API and internal mechanisms are not publicly available through a readily identifiable npm registry entry or a public GitHub repository at the provided link, such utilities typically offer a simple function to map specific keys to their desired replacement values, returning a new URL string. The package is noted to ship with TypeScript types, suggesting good integration for type-safe development environments. Due to the lack of public information, its release cadence and key differentiators beyond its core functionality remain unclear, but it aims to provide a straightforward approach to a common web development task.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install replace-url-values"],"cli":null},"imports":["import { replaceUrlValues } from 'replace-url-values';","import replaceUrlValues from 'replace-url-values';","import * as UrlReplacer from 'replace-url-values';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { replaceUrlValues } from 'replace-url-values';\n\n// Example 1: Replacing placeholders in a URL path like '/products/:productId'\nconst urlTemplateWithPathParams = '/products/:productId/reviews/:reviewId';\nconst pathReplacements = {\n  productId: '456',\n  reviewId: '789'\n};\nconst finalUrl1 = replaceUrlValues(urlTemplateWithPathParams, pathReplacements);\nconsole.log('Replaced path URL:', finalUrl1);\n// Expected output: /products/456/reviews/789\n\n// Example 2: Replacing specific query parameter values in an existing URL\nconst urlWithQueryParams = 'https://example.com/search?q=apple&page=1';\nconst queryReplacements = {\n  q: 'banana and orange', // Replace existing 'q'\n  page: '2',              // Replace existing 'page'\n  sort: 'desc'            // Add a new parameter 'sort'\n};\nconst finalUrl2 = replaceUrlValues(urlWithQueryParams, queryReplacements);\nconsole.log('Replaced query params URL:', finalUrl2);\n// Expected output (order might vary, but parameters should be correct):\n// https://example.com/search?q=banana%20and%20orange&page=2&sort=desc\n\n// Example 3: Handling missing placeholders gracefully (assumption: no change for unmatched keys)\nconst incompleteTemplate = '/users/:userId/profile';\nconst partialReplacements = { userId: '101' };\nconst finalUrl3 = replaceUrlValues(incompleteTemplate, partialReplacements);\nconsole.log('Partial replacements:', finalUrl3);\n// Expected output: /users/101/profile\n\n// Example 4: When no matches are found, the original URL is returned (assumption)\nconst noMatchUrl = 'https://example.com/data';\nconst noMatchReplacements = { unknownKey: 'value' };\nconst finalUrl4 = replaceUrlValues(noMatchUrl, noMatchReplacements);\nconsole.log('No matches:', finalUrl4);","lang":"typescript","description":"Demonstrates replacing both path placeholders and query parameters in a URL string, including adding new parameters and handling URL encoding of replacement values.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}