Skip to content

Commit

Permalink
feat: add support for array in search params
Browse files Browse the repository at this point in the history
  • Loading branch information
eshankvaish committed Feb 8, 2024
1 parent 4ca991d commit 57369a7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@devtron-labs/devtron-fe-common-lib",
"version": "0.0.61-beta-4",
"version": "0.0.61-beta-8",
"description": "Supporting common component library",
"main": "dist/index.js",
"scripts": {
Expand Down
9 changes: 8 additions & 1 deletion src/Common/Helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,16 @@ export const processDeployedTime = (lastDeployed, isArgoInstalled) => {
*/
export const getUrlWithSearchParams = (url: string, params: Record<string | number, any>) => {
const searchParams = new URLSearchParams()
// TODO: Common out
Object.keys(params).forEach((key) => {
if (params[key]) {
searchParams.append(key, params[key])
if (Array.isArray(params[key])) {
params[key].forEach((val) => {
searchParams.append(key, val)
})
} else {
searchParams.set(key, params[key])
}
}
})
const queryString = searchParams.toString()
Expand Down

0 comments on commit 57369a7

Please sign in to comment.