A low level git url parser.
$ npm i --save git-up
// Dependencies
var gitUp = require("git-up");
console.log(gitUp("git@github.com:IonicaBizau/node-parse-url.git"));
// => {
// protocols: []
// , port: null
// , resource: "github.com"
// , user: "git"
// , pathname: "/IonicaBizau/node-parse-url.git"
// , hash: ""
// , search: ""
// , href: "git@github.com:IonicaBizau/node-parse-url.git"
// , protocol: "ssh"
// }
console.log(gitUp("https://github.com/IonicaBizau/node-parse-url.git"));
// => {
// protocols: [ "https" ]
// , port: null
// , resource: "github.com"
// , user: ""
// , pathname: "/IonicaBizau/node-parse-url.git"
// , hash: ""
// , search: ""
// , href: "https://github.com/IonicaBizau/node-parse-url.git"
// , protocol: "https"
// }
Parses the input url.
-
String
input
: The input url.
- Object An object containing the following fields:
-
protocols
(Array): An array with the url protocols (usually it has one element). -
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. -
protocol
(String): The git url protocol. -
token
(String): The oauth token (could appear in the https urls).
Have an idea? Found a bug? See how to contribute.