{"id":21078791,"url":"https://github.com/worka/vanilla-js-url","last_synced_at":"2025-05-16T08:32:03.340Z","repository":{"id":46769698,"uuid":"242341723","full_name":"worka/vanilla-js-url","owner":"worka","description":"A lightweight module to construct and parse query parameters of URLs. A set of functions for working with url. Easy to add parameters to url, easy to extract parameters from url. You can also get path from url.","archived":false,"fork":false,"pushed_at":"2024-09-24T21:41:35.000Z","size":1155,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-07T21:51:57.033Z","etag":null,"topics":["add","add-params-to-url","construct","construct-url","get","get-params-from-url","javascript","js","params","parse","parse-url","url","vanilla"],"latest_commit_sha":null,"homepage":"https://worka.github.io/vanilla-js-url","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/worka.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":"2020-02-22T12:56:49.000Z","updated_at":"2024-09-24T21:41:32.000Z","dependencies_parsed_at":"2024-06-18T00:41:32.699Z","dependency_job_id":"3d211e29-fb1a-4fd1-9a66-f5941e3c7169","html_url":"https://github.com/worka/vanilla-js-url","commit_stats":{"total_commits":83,"total_committers":3,"mean_commits":"27.666666666666668","dds":0.2530120481927711,"last_synced_commit":"2bfd479213f4053d00784058c7a457662ff42a5c"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worka%2Fvanilla-js-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worka%2Fvanilla-js-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worka%2Fvanilla-js-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/worka%2Fvanilla-js-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/worka","download_url":"https://codeload.github.com/worka/vanilla-js-url/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225415179,"owners_count":17470848,"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","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":["add","add-params-to-url","construct","construct-url","get","get-params-from-url","javascript","js","params","parse","parse-url","url","vanilla"],"created_at":"2024-11-19T19:42:22.196Z","updated_at":"2024-11-19T19:42:22.887Z","avatar_url":"https://github.com/worka.png","language":"JavaScript","funding_links":["https://paypal.me/bworka"],"categories":[],"sub_categories":[],"readme":"# vanilla-js-url\n\nA lightweight module to construct and parse query parameters of URLs.\n\nA set of functions for working with url. Easy to add parameters to url, easy to extract parameters from url. You can also get `path` from url.\n\n🖐 If you find my plugin helpful, please \u003ca href=\"https://paypal.me/bworka\"\u003edonate me\u003c/a\u003e 🤝\n\n![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/worka/vanilla-js-url)\n[![GitHub stars](https://img.shields.io/github/stars/worka/vanilla-js-url)](https://github.com/worka/vanilla-js-url/stargazers)\n[![GitHub issues](https://img.shields.io/github/issues/worka/vanilla-js-url)](https://github.com/worka/vanilla-js-url/issues)\n[![GitHub forks](https://img.shields.io/github/forks/worka/vanilla-js-url)](https://github.com/worka/vanilla-js-url/network)\n\n**simple get**, **simple add**\n\n\u003ca href=\"https://worka.github.io/vanilla-js-url/demo.html\"\u003eDemo\u003c/a\u003e\n\n### Install\n\n```cmd\nnpm i vanilla-js-url\n```\n\nor\n\n```cmd\nyarn add vanilla-js-url\n```\n\n### Get started\n\n```javascript\nwurl.getParams('example.com?bar=1\u0026foo');\nwurl.addParams('example.com', { bar: 1, foo: 2 });\n\nwurl.getPath('example.com/path/to/page');\n\nwurl.getParamsExtended('example.com?bar[roo][boo]=1\u0026foo[puu]=test');\nwurl.addParamsExtended('example.com', { bar: { foo: 'test', joo: 2 } });\n````\n\n#### getParams(url, decode)\n`alias get()`\n\n| param  | type    | default              |\n|--------|---------|----------------------|\n| url    | String  | window.location.href |\n| decode | Boolean | true                 |\n\n\u003e If you have simple parameters like `bar=1` or `foo[]=3\u0026foo[]=5`, then use `getParams()`.\u003cbr /\u003e\n\u003e In response, you will get a simple (single-level) object whose keys will contain either simple values or simple arrays.\n\u003e This function is suitable in 99% of cases.\n\n```javascript\nwurl.get('example.com');\n// {}\n\nwurl.get('example.com?bar=1\u0026foo');\n// { bar: '1', foo: '' }\n\nwurl.get('example.com?bar=1\u0026bar=2');\n// { bar: '2' }\n\nwurl.get('example.com?bar[]=1\u0026bar[]=2');\n// { bar: ['1', '2'] }\n\nwurl.get('example.com?bar=1\u0026bar[]=2');\n// { bar: ['2'] }\n```\n\n#### addParams(url, params, encode)\n`alias add()`\n\n| param  | type    | default    |\n|--------|---------|------------|\n| url    | String  | `required` |\n| params | Object  | `required` |\n| encode | Boolean | false      |\n\n```javascript\nwurl.add('example.com', { bar: 1, foo: 2 });\n// example.com?bar=1\u0026foo=2\n\nwurl.add('example.com?bar=1\u0026foo', { bar: 2, foo: 2 });\n// example.com?bar=2\u0026foo=2\n\nwurl.add('example.com?bar=1', { bar: [2, 3] });\n// example.com?bar[]=2\u0026bar[]=3\n\nwurl.add('example.com?bar=1\u0026bar[]=2', { bar: [3, 4] });\n// example.com?bar[]=2\u0026bar[]=3\u0026bar[]=4\n```\n\n#### getPath(url)\n`alias path()`\n\n| param  | type    | default              |\n|--------|---------|----------------------|\n| url    | String  | window.location.href |\n\n```javascript\nwurl.path('https://example.com/path/to/page?bar=1');\n// /path/to/page\n```\n\n#### getParamsExtended(url)\n`alias getExt()`\n\n| param  | type    | default              |\n|--------|---------|----------------------|\n| url    | String  | window.location.href |\n\n\u003e If you have complex parameters like: `bar[foo][too][poo]=3\u0026bar[foo][goo]=4`, then use `getParamsExtended()`.\u003cbr /\u003e\n\u003e In response, you will get a multi-level object.\n\u003e Most likely you will not need this function.\n\n```javascript\nwurl.getExt('example.com?bar[t]=1\u0026bar[j]=2');\n// { bar: { t: '1', j: '2' } }\n```\n\n#### addParamsExtended(url, params)\n`alias addExt()`\n\n| param  | type    | default    |\n|--------|---------|------------|\n| url    | String  | `required` |\n| params | Object  | `required` |\n\n```javascript\nwurl.addExt('example.com', { bar: { foo: 'test', joo: 2 } });\n// example.com?bar[foo]=test\u0026bar[joo]=2\n```\n\nThe `getParamsExtended` and `addParamsExtended` functions may not answer exactly. Please tell me which tests failed.\n\n### MIT LICENSE\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworka%2Fvanilla-js-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworka%2Fvanilla-js-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworka%2Fvanilla-js-url/lists"}