{"id":28545114,"url":"https://github.com/moxystudio/js-proper-url-join","last_synced_at":"2025-07-07T02:30:57.273Z","repository":{"id":57331767,"uuid":"111622592","full_name":"moxystudio/js-proper-url-join","owner":"moxystudio","description":"Like path.join but for a URL","archived":false,"fork":false,"pushed_at":"2024-10-15T12:53:01.000Z","size":651,"stargazers_count":40,"open_issues_count":1,"forks_count":5,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-06-29T04:38:22.343Z","etag":null,"topics":["join","path","pathname","url"],"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/moxystudio.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":"2017-11-22T01:45:08.000Z","updated_at":"2024-11-22T23:28:06.000Z","dependencies_parsed_at":"2024-10-23T17:11:18.566Z","dependency_job_id":null,"html_url":"https://github.com/moxystudio/js-proper-url-join","commit_stats":{"total_commits":58,"total_committers":9,"mean_commits":6.444444444444445,"dds":0.3793103448275862,"last_synced_commit":"f8eb4c38b5f62706cd2ca853d00ff19c75576ac7"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/moxystudio/js-proper-url-join","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxystudio%2Fjs-proper-url-join","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxystudio%2Fjs-proper-url-join/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxystudio%2Fjs-proper-url-join/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxystudio%2Fjs-proper-url-join/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moxystudio","download_url":"https://codeload.github.com/moxystudio/js-proper-url-join/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moxystudio%2Fjs-proper-url-join/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264001871,"owners_count":23542331,"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":["join","path","pathname","url"],"created_at":"2025-06-09T23:06:37.134Z","updated_at":"2025-07-07T02:30:57.267Z","avatar_url":"https://github.com/moxystudio.png","language":"JavaScript","funding_links":[],"categories":["Framework agnostic packages"],"sub_categories":["General utilities"],"readme":"# proper-url-join\n\n[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url]\n\n[npm-url]:https://npmjs.org/package/proper-url-join\n[npm-image]:https://img.shields.io/npm/v/proper-url-join.svg\n[downloads-image]:https://img.shields.io/npm/dm/proper-url-join.svg\n[travis-url]:https://travis-ci.org/moxystudio/js-proper-url-join\n[travis-image]:https://img.shields.io/travis/moxystudio/js-proper-url-join/master.svg\n[codecov-url]:https://codecov.io/gh/moxystudio/js-proper-url-join\n[codecov-image]:https://img.shields.io/codecov/c/github/moxystudio/js-proper-url-join/master.svg\n[david-dm-url]:https://david-dm.org/moxystudio/js-proper-url-join\n[david-dm-image]:https://img.shields.io/david/moxystudio/js-proper-url-join.svg\n[david-dm-dev-url]:https://david-dm.org/moxystudio/js-proper-url-join?type=dev\n[david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/js-proper-url-join.svg\n\nLike `path.join` but for a URL.\n\n\n## Installation\n\n`$ npm install proper-url-join`\n\nThis library expects the host environment to be up-to-date or polyfilled with [core-js](https://github.com/zloirock/core-js) or similar.\n\nThis library is written in ES9 and is using ES modules. You must compile the source code to support older browsers.\n\n\n## Motivation\n\nThere are a lot of packages that attempt to provide this functionality but they all have issues.   \nThis package exists with the hope to do it right:\n\n- Consistent behavior\n- Support adding/removing leading and trailing slashes\n- Supports absolute URLs, e.g.: http//google.com\n- Supports protocol relative URLs, e.g.: //google.com\n- Supports query strings\n\n\n## Usage\n\n```js\nimport urlJoin from 'proper-url-join';\n\nurlJoin('foo', 'bar'); // /foo/bar\nurlJoin('/foo/', '/bar/'); // /foo/bar\nurlJoin('foo', '', 'bar'); // /foo/bar\nurlJoin('foo', undefined, 'bar'); // /foo/bar\nurlJoin('foo', null, 'bar'); // /foo/bar\n\n// With leading \u0026 trailing slash options\nurlJoin('foo', 'bar', { leadingSlash: false }); // foo/bar\nurlJoin('foo', 'bar', { trailingSlash: true }); // /foo/bar/\nurlJoin('foo', 'bar', { leadingSlash: false, trailingSlash: true }); // foo/bar/\n\n// Absolute URLs\nurlJoin('http://google.com', 'foo'); // http://google.com/foo\n\n// Protocol relative URLs\nurlJoin('//google.com', 'foo', { protocolRelative: true }); // //google.com/foo\n\n// With query string as an url part\nurlJoin('foo', 'bar?queryString'); // /foo/bar?queryString\nurlJoin('foo', 'bar?queryString', { trailingSlash: true }); // /foo/bar/?queryString\n\n// With query string as an object\nurlJoin('foo', { query: { biz: 'buz', foo: 'bar' } }); // /foo?biz=buz\u0026foo=bar\n\n// With both query string as an url part and an object\nurlJoin('foo', 'bar?queryString', { query: { biz: 'buz', foo: 'bar' } }); // /foo/bar?biz=buz\u0026foo=bar\u0026queryString\n```\n\n#### options\n\n###### leadingSlash\n\nType: `boolean` / `string`   \nDefault: `true`\n\nAdds or removes leading `/`. You may pass `keep` to preserve what the leading slash only if it's present on the input.\n\n###### trailingSlash\n\nType: `boolean` / `string`   \nDefault: `false`\n\nAdds or removes trailing `/`. You may pass `keep` to preserve what the trailing slash only if it's present on the input.\n\n###### protocolRelative\n\nType: `boolean`   \nDefault: `false`\n\nEnables support for protocol relative URLs\n\n###### query\n\nType: `object`\n\nQuery string object that will be properly stringified and appended to the url. It will be merged with the query string in the url, if it exists.\n\n###### queryOptions\n\nType: `object`\n\n[Options](https://github.com/sindresorhus/query-string#stringifyobject-options) to be considered when stringifying the query\n\n\n\n## Tests\n\n`$ npm test`   \n`$ npm test -- --watch` during development\n\n\n## License\n\n[MIT License](http://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxystudio%2Fjs-proper-url-join","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoxystudio%2Fjs-proper-url-join","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoxystudio%2Fjs-proper-url-join/lists"}