{"id":13526230,"url":"https://github.com/jfromaniello/url-join","last_synced_at":"2025-05-14T23:00:16.538Z","repository":{"id":6650737,"uuid":"7895083","full_name":"jfromaniello/url-join","owner":"jfromaniello","description":"Join all arguments together and normalize the resulting url.","archived":false,"fork":false,"pushed_at":"2024-05-06T08:12:23.000Z","size":174,"stargazers_count":362,"open_issues_count":5,"forks_count":46,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-08T06:03:14.085Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/jfromaniello.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2013-01-29T15:39:51.000Z","updated_at":"2025-03-03T08:47:35.000Z","dependencies_parsed_at":"2022-08-30T20:01:06.427Z","dependency_job_id":"ecafdfe2-e206-4ac7-b723-d534a43366b5","html_url":"https://github.com/jfromaniello/url-join","commit_stats":{"total_commits":73,"total_committers":9,"mean_commits":8.11111111111111,"dds":0.589041095890411,"last_synced_commit":"a9ce522aa5ea42ed6c304fc0a1d9ac9d0f2eff68"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfromaniello%2Furl-join","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfromaniello%2Furl-join/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfromaniello%2Furl-join/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jfromaniello%2Furl-join/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jfromaniello","download_url":"https://codeload.github.com/jfromaniello/url-join/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253708794,"owners_count":21951057,"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":[],"created_at":"2024-08-01T06:01:26.671Z","updated_at":"2025-05-14T23:00:16.298Z","avatar_url":"https://github.com/jfromaniello.png","language":"JavaScript","funding_links":[],"categories":["Repository","JavaScript"],"sub_categories":["URL"],"readme":"Join all arguments together and normalize the resulting URL.\n\n## Install\n\n```bash\nnpm install url-join\n```\n\nIf you want to use it directly in a browser use a CDN like [Skypack](https://www.skypack.dev/view/url-join).\n\n## Usage\n\n```javascript\nimport urlJoin from 'url-join';\n\nconst fullUrl = urlJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '\u0026bar=456', '#heading-1');\n\nconsole.log(fullUrl.toString()); // 'http://www.google.com/a/b/cd?foo=123\u0026bar=456#heading-1'\n```\n\n## You might not need this library\n\nThis library was originally created before the [URL API](https://developer.mozilla.org/en-US/docs/Web/API/URL_API) was standardized and widely available in popular runtimes such as browsers and Node.js. Depending on your use-case you might want to consider using the standardized API over this library.\n\n### In the Browser\n\nFor example, the equivalent code for the above example would look as follows when using the URL API:\n\n```javascript\nconst fullUrl = new URL('http://www.google.com');\n\nfullUrl.pathname = '/a/b/cd';\nfullUrl.searchParams.append('foo', '123');\nfullUrl.searchParams.append('bar', '456');\nfullUrl.hash = 'heading-1';\n\nconsole.log(fullUrl.toString()); // 'http://www.google.com/a/b/cd?foo=123\u0026bar=456#heading-1'\n```\n\n### Joining paths\n\nThis library provides the missing piece for the URL API, joining multiple paths together:\n\n```javascript\nimport urlJoin from 'url-join';\n\nconst fullUrl = new URL('http://www.google.com');\n\nfullUrl.pathname = urlJoin('a', '/b/cd');\n\nconsole.log(fullUrl.toString()); // 'http://www.google.com/a/b/cd'\n```\n\n### In Node.js\n\nIf you are using Node.js, the `path/posix` module can join paths in a way that is compatible with URL pathnames:\n\n```javascript\nimport { join as joinPath } from 'node:path/posix';\n\nconst fullUrl = new URL('http://www.google.com');\n\nfullUrl.pathname = joinPath('a', '/b/cd');\n\nconsole.log(fullUrl.toString()); // 'http://www.google.com/a/b/cd'\n```\n\n### Caveats of URL API\n\nThere are a couple of caveats to take into account when utilizing the standard APIs. Firstly, a `URL` must always include a complete and valid base, which means specifying the scheme and domain name (e.g. http://example.com).\n\nSecondly, it is not possible to join together and normalize the path of a URL. You must do this manually by joining your paths and then assigning the pathname property.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfromaniello%2Furl-join","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjfromaniello%2Furl-join","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjfromaniello%2Furl-join/lists"}