{"id":15774185,"url":"https://github.com/just-paja/js-query-string-manipulator","last_synced_at":"2025-08-13T06:03:43.965Z","repository":{"id":43885123,"uuid":"116948437","full_name":"just-paja/js-query-string-manipulator","owner":"just-paja","description":"Simply manipulate query string parameters","archived":false,"fork":false,"pushed_at":"2023-03-01T13:11:40.000Z","size":1468,"stargazers_count":3,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T13:52:58.970Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/just-paja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-10T11:23:30.000Z","updated_at":"2022-02-14T12:42:32.000Z","dependencies_parsed_at":"2024-06-19T22:49:26.914Z","dependency_job_id":"8c4f2c37-f8db-46f1-84e0-a0cbb7bb13b4","html_url":"https://github.com/just-paja/js-query-string-manipulator","commit_stats":null,"previous_names":["berrycloud/js-query-string-manipulator"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/just-paja/js-query-string-manipulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-paja%2Fjs-query-string-manipulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-paja%2Fjs-query-string-manipulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-paja%2Fjs-query-string-manipulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-paja%2Fjs-query-string-manipulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/just-paja","download_url":"https://codeload.github.com/just-paja/js-query-string-manipulator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/just-paja%2Fjs-query-string-manipulator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270191401,"owners_count":24542267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-13T02:00:09.904Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T16:20:26.797Z","updated_at":"2025-08-13T06:03:43.902Z","avatar_url":"https://github.com/just-paja.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Query String Manipulator\n\n[![CircleCI](https://circleci.com/gh/BerryCloud/js-query-string-manipulator.svg?style=shield)](https://circleci.com/gh/BerryCloud/js-query-string-manipulator)\n\nEffortlessly manipulate query string parameters into your desired URL. You pass url and a set of actions to be done to QSM and you get you URL string back.\n\n## Install\n\nQSM is written for ES modules\n\n```javascript\nnpm install query-string-manipulator\n```\n\n## Usage\n\nLets assume that you already have it imported\n\n```javascript\nimport qsm from 'query-string-manipulator';\n```\n\n### Set parameters\n\nLets say that you want to add page number to a search result.\n\n```javascript\nqsm('https://www.google.cz/search?q=hello+world', {\n  set: {\n    num: 20,\n  }\n});\n// https://www.google.cz/search?q=hello+world\u0026num=20\n```\n\nIt also works if the page number is already set\n\n```javascript\nqsm('https://www.google.cz/search?q=hello+world\u0026num=20', {\n  set: {\n    num: 40,\n  }\n});\n// https://www.google.cz/search?q=hello+world\u0026num=40\n```\n\nIt also works when passing a parameter as an array.\n\n```javascript\nqsm('https://www.google.cz/search?q=hello+world\u0026num=20', {\n  set: {\n    num: [20, 40, 60],\n  }\n});\n// https://www.google.cz/search?q=hello+world\u0026num=20\u0026num=40\u0026num=60\n```\n\n### Remove parameters\n\nSay that you now want to go back to first page\n\n```javascript\nqsm('https://www.google.cz/search?q=hello+world\u0026num=20', {\n  remove: ['num']\n});\n// https://www.google.cz/search?q=hello+world\n```\n\nOr go to the empty search page\n```javascript\nqsm('https://www.google.cz/search?q=hello+world\u0026num=20', {\n  remove: ['q', 'num']\n});\n// https://www.google.cz/search\n```\n\n### Toggle parameters\n\nSay that you have a button on your page that enables filter and disables it when you click it again.\n```javascript\nqsm('https://www.google.cz/search?q=hello+world\u0026num=20', {\n  toggle: {\n    tbm: 'isch',\n  }\n});\n// https://www.google.cz/search?q=hello+world\u0026num=20\u0026tbm=isch\n\nqsm('https://www.google.cz/search?q=hello+world\u0026num=20\u0026tbm=isch', {\n  toggle: {\n    tbm: 'isch',\n  }\n});\n// https://www.google.cz/search?q=hello+world\u0026num=20\n```\n\n\n### Constants\n\nIf you like \"symbols\", you can go like this:\n\n```javascript\nimport qsm, {\n  URL_REMOVE, // Used for remove\n  URL_SET, // Used for set\n  URL_TOGGLE, // Used for toggle\n} from 'query-string-manipulator';\n\nqsm('http://example.com/', {\n  [URL_REMOVE]: ['test'],\n  [URL_TOGGLE]: {\n    foo: 'bar',\n  },\n  [URL_SET]: {\n    xxx: '123',\n  },\n})\n```\n\n### Support methods\n\nBut wait, there is more!\n\n#### Getting URL params\n\nMethod `getUrlParams` returns list of all parameters in form of array of objects. It cannot be returned in form of key-pair values because there can be multiple same name query params.\n\n```javascript\ngetUrlParams('https://example.com/foo?select=users\u0026getId=10')\n\n/* returns\n[\n  {\n    key: 'select',\n    value: 'users'\n  },\n  {\n    key: 'getId',\n    value: '10',\n  }\n]\n*/\n```\n\n#### Resolve URL params\n\nMethod `resolveUrlParams` returns parameters after changed by user specified actions.\n\n```javascript\nconst urlParams = [\n  {\n    key: 'select',\n    value: 'users'\n  },\n  {\n    key: 'getId',\n    value: '10'\n  }\n];\nconst paramActions = {\n  remove: ['getId'],\n  set: {\n    select: 'userGroups',\n  },\n};\nresolveUrlParams(urlParams, paramActions)\n\n/* returns\n[\n  {\n    key: 'select',\n    value: 'userGroups'\n  }\n]\n*/\n```\n\n#### Putting params together\n\nMethod `constructUrlParams` returns query string part of the URL from parameters.\n\n```javascript\nconstructUrlParams([\n  {\n    key: 'select',\n    value: 'users'\n  },\n  {\n    key: 'getId',\n    value: '10'\n  }\n])\n\n// returns \"select=users\u0026getId=10\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-paja%2Fjs-query-string-manipulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjust-paja%2Fjs-query-string-manipulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjust-paja%2Fjs-query-string-manipulator/lists"}