{"id":15718155,"url":"https://github.com/unstubbable/universal-parse-url","last_synced_at":"2025-07-20T21:34:15.021Z","repository":{"id":57386619,"uuid":"78753465","full_name":"unstubbable/universal-parse-url","owner":"unstubbable","description":"🔗 A universal URL parser for Node.js and browser environments with a minimal footprint.","archived":false,"fork":false,"pushed_at":"2017-11-22T11:48:35.000Z","size":46,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-11T00:50:54.013Z","etag":null,"topics":["universal","url-parser"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/unstubbable.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}},"created_at":"2017-01-12T14:27:14.000Z","updated_at":"2023-09-08T17:19:19.000Z","dependencies_parsed_at":"2022-09-05T13:40:45.402Z","dependency_job_id":null,"html_url":"https://github.com/unstubbable/universal-parse-url","commit_stats":null,"previous_names":["kinghenne/universal-parse-url"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/unstubbable/universal-parse-url","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unstubbable%2Funiversal-parse-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unstubbable%2Funiversal-parse-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unstubbable%2Funiversal-parse-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unstubbable%2Funiversal-parse-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unstubbable","download_url":"https://codeload.github.com/unstubbable/universal-parse-url/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unstubbable%2Funiversal-parse-url/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265248805,"owners_count":23734315,"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":["universal","url-parser"],"created_at":"2024-10-03T21:52:16.938Z","updated_at":"2025-07-20T21:34:15.005Z","avatar_url":"https://github.com/unstubbable.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# universal-parse-url\n\n[![NPM][npm-image]][npm-url]\n[![Travis Build Status][travis-image]][travis-url]\n[![Commitizen Friendly][commitizen-image]][commitizen-url]\n[![MIT License][license-image]][license-url]\n\n[![Sauce Labs Build Status][saucelabs-image]][saucelabs-url]\n\nA universal URL parser for Node.js and browser environments with a minimal footprint (gzipped **only 600 bytes** for the browser version).\n\n## Installation\n\nInstall with `npm`:\n\n```sh\nnpm install --save universal-parse-url\n```\n\n**Note:** The installed node module also includes a `d.ts` file, and thus works out of the box with **TypeScript**.\n\n## Usage\n\n```js\nimport { parseURL } from 'universal-parse-url';\nconst url = parseURL('http://www.example.com:1234/foo?bar=1#baz');\n```\n\nThe resulting `url` object looks like this:\n\n```\n{\n  hash: '#baz',\n  host: 'www.example.com:1234',\n  hostname: 'www.example.com',\n  href: 'http://www.example.com:1234/foo?bar=1#baz',\n  pathname: '/foo',\n  port: '1234',\n  protocol: 'http:',\n  search: '?bar=1'\n}\n```\n\n## How It Works\n\n- In Node.js `parseURL` just delegates to [URL.parse][].\n- In browser environments:\n  - An [HTMLAnchorElement][] is created initially (with `document.createElement('a')`).\n  - When `parseURL` is called, the `href` attribute of this element is set to the given url string.\n  - The element is then used to extract the URL details.\n\n## Requirements\n\nIf you plan on targeting browser environments as well, you need to use a bundler like [Webpack][], [Browserify][] or [Rollup][] (with [rollup-plugin-node-resolve][]) that makes use of the `browser` field in the `package.json`.\n\n## Caveats\n\nTo keep `universal-parse-url` as small and simple as possible, only the URL details that are available in Node’s `URL` object as well as `HTMLAnchorElement` are supported (see the above example).\n\n[npm-image]: https://img.shields.io/npm/v/universal-parse-url.svg\n[npm-url]: https://www.npmjs.com/package/universal-parse-url\n\n[travis-image]: https://img.shields.io/travis/KingHenne/universal-parse-url.svg\n[travis-url]: https://travis-ci.org/KingHenne/universal-parse-url\n\n[license-image]: https://img.shields.io/github/license/kinghenne/universal-parse-url.svg\n[license-url]: https://github.com/KingHenne/universal-parse-url/blob/master/LICENSE\n\n[commitizen-image]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg\n[commitizen-url]: http://commitizen.github.io/cz-cli/\n\n[saucelabs-image]: https://saucelabs.com/browser-matrix/KingHenne.svg\n[saucelabs-url]: https://saucelabs.com/u/KingHenne\n\n[URL.parse]: https://nodejs.org/dist/latest-v6.x/docs/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost\n[HTMLAnchorElement]: https://developer.mozilla.org/de/docs/Web/API/HTMLAnchorElement\n[Webpack]: https://webpack.js.org\n[Browserify]: http://browserify.org\n[Rollup]: http://rollupjs.org\n[rollup-plugin-node-resolve]: https://github.com/rollup/rollup-plugin-node-resolve\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funstubbable%2Funiversal-parse-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funstubbable%2Funiversal-parse-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funstubbable%2Funiversal-parse-url/lists"}