17
17
18
18
# git-url-parse [ ![ Donate now] [ donate-now ]] [ paypal-donations ]
19
19
20
- Parses and stringifies git urls .
20
+ A high level git url parser for common git providers .
21
21
22
22
## Installation
23
23
@@ -32,26 +32,46 @@ $ npm i git-url-parse
32
32
var GitUrlParse = require (" git-url-parse" );
33
33
34
34
console .
log (
GitUrlParse (
" [email protected] :IonicaBizau/node-git-url-parse.git" ));
35
- // => { protocol: 'ssh'
36
- // , source: 'github.com'
37
- // , owner: 'IonicaBizau'
38
- // , name: 'node-git-url-parse'
39
- // , _: '[email protected] :IonicaBizau/node-git-url-parse.git'
40
- // , toString: [Function] }
35
+ // => {
36
+ // protocols: []
37
+ // , port: null
38
+ // , resource: "github.com"
39
+ // , user: "git"
40
+ // , pathname: "/IonicaBizau/node-git-url-parse.git"
41
+ // , hash: ""
42
+ // , search: ""
43
+ // , href: "[email protected] :IonicaBizau/node-git-url-parse.git"
44
+ // , token: ""
45
+ // , protocol: "ssh"
46
+ // , toString: [Function]
47
+ // , source: "github.com"
48
+ // , name: "node-git-url-parse"
49
+ // , owner: "IonicaBizau"
50
+ // } {
41
51
42
52
console .log (GitUrlParse (" https://github.com/IonicaBizau/node-git-url-parse.git" ));
43
- // => { protocol: 'https'
44
- // , source: 'github.com'
45
- // , owner: 'IonicaBizau'
46
- // , name: 'node-git-url-parse'
47
- // , _: 'https://github.com/IonicaBizau/node-git-url-parse.git'
48
- // , toString: [Function] }
53
+ // => {
54
+ // protocols: ["https"]
55
+ // , port: null
56
+ // , resource: "github.com"
57
+ // , user: ""
58
+ // , pathname: "/IonicaBizau/node-git-url-parse.git"
59
+ // , hash: ""
60
+ // , search: ""
61
+ // , href: "https://github.com/IonicaBizau/node-git-url-parse.git"
62
+ // , token: ""
63
+ // , protocol: "https"
64
+ // , toString: [Function]
65
+ // , source: "github.com"
66
+ // , name: "node-git-url-parse"
67
+ // , owner: "IonicaBizau"
68
+ // }
49
69
50
70
console .log (GitUrlParse (" https://github.com/IonicaBizau/node-git-url-parse.git" ).toString (" ssh" ));
51
- // => ' [email protected] :IonicaBizau/node-git-url-parse.git.git'
71
+ // => " [email protected] :IonicaBizau/node-git-url-parse.git"
52
72
53
73
console .
log (
GitUrlParse (
" [email protected] :IonicaBizau/node-git-url-parse.git" ).
toString (
" https" ));
54
- // => ' https://github.com/IonicaBizau/node-git-url-parse.git'
74
+ // => " https://github.com/IonicaBizau/node-git-url-parse.git"
55
75
56
76
```
57
77
@@ -65,12 +85,21 @@ Parses a Git url.
65
85
66
86
#### Return
67
87
- ** GitUrl** The ` GitUrl ` object containing:
68
- - ` protocol ` (String): The url protocol.
88
+ - ` protocols ` (Array): An array with the url protocols (usually it has one element).
89
+ - ` port ` (null|Number): The domain port.
90
+ - ` resource ` (String): The url domain (including subdomains).
91
+ - ` user ` (String): The authentication user (usually for ssh urls).
92
+ - ` pathname ` (String): The url pathname.
93
+ - ` hash ` (String): The url hash.
94
+ - ` search ` (String): The url querystring value.
95
+ - ` href ` (String): The input url.
96
+ - ` protocol ` (String): The git url protocol.
97
+ - ` token ` (String): The oauth token (could appear in the https urls).
69
98
- ` source ` (String): The Git provider (e.g. ` "github.com" ` ).
70
99
- ` owner ` (String): The repository owner.
71
100
- ` name ` (String): The repository name.
72
- - ` _ ` (String): The original url which was parsed.
73
101
- ` toString ` (Function): A function to stringify the parsed url into another url type.
102
+ - ` organization ` (String): The organization the owner belongs to. This is CloudForge specific.
74
103
75
104
### ` stringify(obj, type) `
76
105
Stringifies a ` GitUrl ` object.
0 commit comments