{"library":"parse-url","title":"Advanced URL Parser (Including Git URLs)","description":"parse-url is a JavaScript/TypeScript library designed for advanced URL parsing, notably providing robust support for various Git URL formats (e.g., `git+ssh://`, `git@github.com`). It goes beyond standard URL parsing by offering detailed breakdown into components like protocols, resource, user, pathname, hash, search, and query object. The current stable version is 11.1.0, with a release cadence that includes major version updates roughly annually and more frequent minor/patch releases to address issues and update dependencies. A key differentiator is its explicit handling of Git URLs and the ability to control URL normalization via options passed to the underlying `normalize-url` library, offering more granular control than built-in or simpler parsers.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install parse-url"],"cli":null},"imports":["import parseUrl from 'parse-url';","import type { ParseUrlResult } from 'parse-url';","import parseUrl from 'parse-url/dist/index.mjs';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import parseUrl from 'parse-url';\n\n// Example 1: Standard HTTP URL parsing\nconsole.log('HTTP URL:', parseUrl(\"http://ionicabizau.net/blog\"));\n/*\nOutput: {\n  protocols: [ 'http' ], protocol: 'http', port: '',\n  resource: 'ionicabizau.net', user: '', password: '',\n  pathname: '/blog', hash: '', search: '',\n  href: 'http://ionicabizau.net/blog', query: {}\n}\n*/\n\n// Example 2: URL with query parameters and hash\nconsole.log('\\nURL with query/hash:', parseUrl(\"http://domain.com/path/name?foo=bar&bar=42#some-hash\"));\n/*\nOutput: {\n  protocols: [ 'http' ], protocol: 'http', port: '',\n  resource: 'domain.com', user: '', password: '',\n  pathname: '/path/name', hash: 'some-hash', search: 'foo=bar&bar=42',\n  href: 'http://domain.com/path/name?foo=bar&bar=42#some-hash',\n  query: { foo: 'bar', bar: '42' }\n}\n*/\n\n// Example 3: Parsing a Git SSH URL, explicitly disabling automatic normalization\nconsole.log('\\nGit SSH URL (normalized: false):', parseUrl(\"git+ssh://git@host.xz/path/name.git\", false));\n/*\nOutput: {\n  protocols: [ 'git', 'ssh' ], protocol: 'git', port: '',\n  resource: 'host.xz', user: 'git', password: '',\n  pathname: '/path/name.git', hash: '', search: '',\n  href: 'git+ssh://git@host.xz/path/name.git', query: {}\n}\n*/\n\n// Example 4: Short-hand Git SSH URL (normalized: false)\nconsole.log('\\nShort-hand Git SSH URL (normalized: false):', parseUrl(\"git@github.com:IonicaBizau/git-stats.git\", false));\n/*\nOutput: {\n  protocols: [ 'ssh' ], protocol: 'ssh', port: '',\n  resource: 'github.com', user: 'git', password: '',\n  pathname: '/IonicaBizau/git-stats.git', hash: '', search: '',\n  href: 'git@github.com:IonicaBizau/git-stats.git', query: {}\n}\n*/","lang":"typescript","description":"This quickstart demonstrates how to parse various URL formats, including standard HTTP(S) URLs with query strings and hashes, and complex Git SSH URLs, highlighting the use of the `normalize` parameter.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}