![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
inserturlparams
Advanced tools
Insert dynamic data in url path/search params. Works client side or in NodeJS. Really useful for big web projects where you store large numbers of long urls.
/:
. i.e. /api/v1/:param/hello
with a value from an array or object.insertUrlParams(urlString, pathParams) => full-url-string
.npm i -s inserturlparams
null
and undefined
will still be included.,
. Empty strings/arrays and undefined
will be
skipped but null
will still be included.import insertUrlParams, {
TParamObj,
TParam,
TSearchParams,
} from '../';
// Example 1: Object keys must match the param names in the url.
const data1: TParamObj = {
id: 5,
msg: 'hello',
really: true,
something: undefined,
random: null,
};
const url1 = '/api/v1/:id/cheese/:msg/is-good/:really/dog/cow/:something/:random';
const resp1 = insertUrlParams(url1, data1);
console.log(resp1); // "/api/v1/5/cheese/hello/is-good/true/dog/cow/undefined/null"
// Example 2: NOTE The array must be in the order that you intend to replace them
// with in the url and the length of the array must match the number of params.
const data2: TParam[] = [5, 'hello', true, undefined, null];
const url2 = '/api/v1/:id/cheese/:msg/is-good/:really/dog/cow/:something/:random';
const resp2 = insertUrlParams(url2, data2);
console.log(resp2); // "/api/v1/5/cheese/hello/is-good/true/dog/cow/undefined/null"
// Example 3: You can use a single primtive.
const resp3 = insertUrlParams('/api/v1/:id/cheese', 5);
console.log(resp3); // "/api/v1/5/cheese";
rollup.js
. In my front-end I had a large Routes.ts
file
and for readability I wanted to store the routes there the same as how they appeared
in express, that is with /:
inside the url. This required me to format the url before
each api call though so I wrote this function to do just that.Happy web-deving :)
FAQs
Insert dynamic data into url path params
The npm package inserturlparams receives a total of 550 weekly downloads. As such, inserturlparams popularity was classified as not popular.
We found that inserturlparams demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.