Package Exports
- parse-url
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-url) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
parse-url
An advanced url parser supporting git urls too.
☁️ Installation
$ npm i --save parse-url
📋 Example
// Dependencies
const parseUrl = require("parse-url");
console.log(parseUrl("http://ionicabizau.net/blog"));
// { protocols: [ 'http' ],
// protocol: 'http',
// port: null,
// resource: 'ionicabizau.net',
// user: '',
// pathname: '/blog',
// hash: '',
// search: '',
// href: 'http://ionicabizau.net/blog' }
console.log(parseUrl("http://domain.com/path/name?foo=bar&bar=42#some-hash"));
// { protocols: [ 'http' ],
// protocol: 'http',
// port: null,
// resource: 'domain.com',
// user: '',
// pathname: '/path/name',
// hash: 'some-hash',
// search: 'foo=bar&bar=42',
// href: 'http://domain.com/path/name?foo=bar&bar=42#some-hash' }
console.log(parseUrl("git+ssh://git@host.xz/path/name.git"));
// { protocols: [ 'git', 'ssh' ],
// protocol: 'git',
// port: null,
// resource: 'host.xz',
// user: 'git',
// pathname: '/path/name.git',
// hash: '',
// search: '',
// href: 'git+ssh://git@host.xz/path/name.git' }
console.log(parseUrl("git@github.com:IonicaBizau/git-stats.git"));
// { protocols: [],
// protocol: 'ssh',
// port: null,
// resource: 'github.com',
// user: 'git',
// pathname: '/IonicaBizau/git-stats.git',
// hash: '',
// search: '',
// href: 'git@github.com:IonicaBizau/git-stats.git' }
📝 Documentation
parseUrl(url)
Parses the input url.
Params
- String
url
: The input url.
Return
- Object An object containing the following fields:
protocols
(Array): An array with the url protocols (usually it has one element).protocol
(String): The first protocol,"ssh"
(if the url is a ssh url) or"file"
.port
(null|Number): The domain port.resource
(String): The url domain (including subdomains).user
(String): The authentication user (usually for ssh urls).pathname
(String): The url pathname.hash
(String): The url hash.search
(String): The url querystring value.href
(String): The input url.
😋 How to contribute
Have an idea? Found a bug? See how to contribute.
💰 Donations
Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. 🚀
PayPal donations are appreciated too! Each dollar helps.
Thanks! ❤️
💫 Where is this library used?
If you are using this library in one of your projects, add it in this list. ✨
deploy-versioning
—Deploy your code keeping older versions.git-up
—A low level git url parser.hubot-will-it-connect
(by gambtho)—Connects hubot with willitconnect, to validate CF's ability to connect to external resourceskakapo
(by devlucky)—Next generation mocking framework in Javascriptlien
—Another lightweight NodeJS framework. Lien is the link between request and response objects.microbe.js
(by Brandon Dail)—A small Node.js framework for simple routingnative-zip
(by kardel)—app内H5应用本地化打包工具,支持增量打包,全量打包tumblr-text
(by cobaimelan)—[
](https://david-dm.org/ayhan
url-local
—Checks if a given url is a local url or not.