ionicabizau / git-url-parse Goto Github PK
View Code? Open in Web Editor NEW:v: A high level git url parser for common git providers.
License: MIT License
:v: A high level git url parser for common git providers.
License: MIT License
The hostname of our GitHub Enterpise looks like this: my.ghe.host.name
and the first part (my
) is getting truncated because of the logic here: https://github.com/IonicaBizau/git-url-parse/blob/master/lib/index.js#L52
Current result:
{
...
source: "ghe.host.name"
}
Expected:
{
...
source: "my.ghe.host.name"
}
A dependency to parse-domain was added in #56.
parse-domain
download and copy locally some files on a postinstall
script.
As git-url-parse
is a fairly small and dependency free module and it was possible to use it anywhere really easily like in a browser or an environment without open access to inter (only access to a npm registry replica).
With the parse-domain
dependency it's not possible anymore. In addition the download mechanism create issues for many users: peerigon/parse-domain#35 for a month and a half now.
Would you consider reverting the changes added in #56 to remove the dependency to parse-domain
and possibly later find an alternate solution to fix #56?
Thanks!
Version: 9.0.0
Reproduction:
const GitUrlParse = require('git-url-parse');
console.log(GitUrlParse('https://github.com/IonicaBizau/git-url-parse').full_name); 'IonicaBizau/git-url-parse'
console.log(GitUrlParse('IonicaBizau/git-url-parse').full_name); // 'onicaBizau/git-url-parse'
Expected result: in the second case it either recognizes it as a relative path and parses it correctly, or indicate that it could not parse. Shouldn't return this wrong and meaningless result.
parse(`[email protected]/really-long-group/with-really-long-sub-group/and-a-really-long-project-name.git`)
Returns the following results:
{ protocols: [],
protocol: 'file',
port: null,
resource: '',
user: '',
pathname: '[email protected]/really-long-group/with-really-long-sub-group/and-a-really-long-project-name.git',
hash: '',
search: '',
href: '[email protected]/really-long-group/with-really-long-sub-group/and-a-really-long-project-name.git',
query: {},
token: '',
toString: [Function],
source: '',
git_suffix: true,
name: 'and-a-really-long-project-name',
owner: '[email protected]/really-long-group/with-really-long-sub-group',
commit: undefined,
ref: '',
filepathtype: '',
filepath: '',
organization: '[email protected]/really-long-group/with-really-long-sub-group',
full_name: '[email protected]/really-long-group/with-really-long-sub-group/and-a-really-long-project-name' }
I was hoping it would return the following properties:
{
resource: 'gitlab.com',
name: `and-a-really-long-project-name`,
owner: `really-long-group/with-really-long-sub-group`
}
It pulled out the name
as desired, but not the resource
or owner
.
For example, https://github.com/IonicaBizau/git-url-parse/commits/master
is a valid URL as per GitHub, but git-url-parse fails to parse and returns:
{
protocols: [ 'https' ],
protocol: 'https',
port: null,
resource: 'github.com',
user: '',
pathname: '/IonicaBizau/git-url-parse/commits/master',
hash: '',
search: '',
href: 'https://github.com/IonicaBizau/git-url-parse/commits/master',
query: [Object: null prototype] {},
token: '',
toString: [Function],
source: 'github.com',
git_suffix: false,
name: 'master',
owner: 'IonicaBizau/git-url-parse/commits',
commit: undefined,
ref: '',
filepathtype: '',
filepath: '',
organization: 'IonicaBizau/git-url-parse/commits',
full_name: 'IonicaBizau/git-url-parse/commits/master'
}
see owner, commit, ref etc...
e.g. https://github.com/IonicaBizau/node-giturlparse/
It's common to see branch names that follows the git flow, eg something like features/LGT-343-crud
for the parser to correctly parsing the ref
and filepath
it would need information of what branches there exists for a given repo...
take this for example: https://github.com/node-fetch/node-fetch/blob/dependabot/npm_and_yarn/tsd-0.20.0/.gitignore
the ref
should be dependabot/npm_and_yarn/tsd-0.20.0
and the filepath should be .gitignore
it's possible to get all the branches from githubs api using: https://api.github.com/repos/node-fetch/node-fetch/branches
Hi, when running gitUrlParse('https://bitbucket.org/org-name/project-name/src/master/ops/assets/');
I would expected to receive this
{
"protocols": [
"https"
],
"protocol": "https",
"port": null,
"resource": "bitbucket.org",
"user": "",
"pathname": "/org-name/project-name/src/master/ops/assets",
"hash": "",
"search": "",
"href": "https://bitbucket.org/org-name/project-name/src/master/ops/assets",
"token": "",
"source": "bitbucket.org",
"git_suffix": false,
"name": "project-name",
"owner": "org-name",
"commit": "master",
"ref": "master",
"filepathtype": "src",
"filepath": "ops/assets",
"organization": "org-name",
"full_name": "org-name/project-name"
}
but instead I'm getting
{
"protocols": [
"https"
],
"protocol": "https",
"port": null,
"resource": "bitbucket.org",
"user": "",
"pathname": "/org-name/project-name/src/master/ops/assets",
"hash": "",
"search": "",
"href": "https://bitbucket.org/org-name/project-name/src/master/ops/assets",
"query": {},
"token": "",
"source": "bitbucket.org",
"git_suffix": false,
"name": "assets",
"owner": "org-name/project-name/src/master/ops",
"ref": "",
"filepathtype": "",
"filepath": "",
"organization": "org-name/project-name/src/master/ops",
"full_name": "org-name/project-name/src/master/ops/assets"
}
Just as a matter of test, if I changes /src/
with /tree/
it works fine and gives me:
{
"protocols": [
"https"
],
"protocol": "https",
"port": null,
"resource": "bitbucket.org",
"user": "",
"pathname": "/org-name/project-name/tree/master/ops/assets",
"hash": "",
"search": "",
"href": "https://bitbucket.org/org-name/project-name/tree/master/ops/assets",
"query": {},
"token": "",
"source": "bitbucket.org",
"git_suffix": false,
"name": "project-name",
"owner": "org-name",
"commit": "master",
"ref": "master",
"filepathtype": "tree",
"filepath": "ops/assets",
"organization": "org-name",
"full_name": "org-name/project-name"
}
Some GitLab Web Project URLs now sometimes have dashes in their path. This is dependent on the version of GitLab and when it is the case GitLab will redirect for some.
The library correctly parses GitLab URLs with /-/
scope.
name
, full_name
, organization
, owner
are incorrect
~ ❯ node Welcome to Node.js v12.18.2.
Type ".help" for more information.
> parse = require('./lib/index.js')
[Function: gitUrlParse] { stringify: [Function] }
> parse("https://gitlab.com/a/b/c/d/-/blob/master/test/index.js")
{
protocols: [ 'https' ],
protocol: 'https',
port: null,
resource: 'gitlab.com',
user: '',
pathname: '/a/b/c/d/-/blob/master/test/index.js',
hash: '',
search: '',
href: 'https://gitlab.com/a/b/c/d/-/blob/master/test/index.js',
query: [Object: null prototype] {},
token: '',
toString: [Function],
source: 'gitlab.com',
git_suffix: false,
name: '-',
owner: 'a/b/c/d',
commit: 'master',
ref: 'master',
filepathtype: 'blob',
filepath: 'test/index.js',
organization: 'a/b/c/d',
full_name: 'a/b/c/d/-'
}
This will really help if we wanna access the repo without git but its website, some tools may not work fine with the http redirect, and also, there may be a repo without .git
postfix, I would like to have an option to disable that, thanks.
Hi, there appears to be a bug when parsing remote URLs that use SSH and have no owner/organisation.
> remote = '[email protected]:repo.git'
'[email protected]:repo.git'
> parsed = GitUrlParse(remote)
{ protocols: [],
protocol: 'ssh',
port: null,
resource: 'gitlab.com',
user: 'git',
pathname: '/repo.git',
hash: '',
search: '',
href: '[email protected]:repo.git',
token: '',
toString: [Function],
source: 'gitlab.com',
name: 'repo',
owner: 'git',
git_suffix: false,
ref: '',
filepathtype: '',
filepath: '',
organization: 'git',
full_name: 'git/repo' }
> parsed.toString('https')
'https://gitlab.com/git/repo.git'
The expected behaviour is
> parsed.toString('https')
'https://gitlab.com/repo.git'
I'm running the latest version (8.2.0).
For example, when parsing https://example.com:7443/scm/ramiro/my-repo.git
the value of owner is "scm/ramiro" instead of "ramiro"
See https://runkit.com/embed/wvfh1js176ot for a full example
When parsing a URL with a basic auth (i.g. http://user:[email protected]
) the auth part is correctly parsed in the user
prop:
gitUrlParse('http://user:[email protected]/aaaa/bbb');
/*
{
...
user: 'user:pass',
...
}
*/
However when calling toString('http')
or toString('https')
on the result object the stringified URL miss the basic auth part:
gitUrlParse('http://user:[email protected]/aaaa/bbb').toString('https')
// => Result: 'https://github.com/aaaa/bbb'
// => Should be 'https://user:[email protected]/aaaa/bbb'
if you parsed a four level domain, which like 'https://registry.code.dev.company.top'
you can get the parsed object is source=code.dev.company.top
but i hope source=registry.code.dev.company.top
thanks your help.
While using npm package semantic-release
they will check the validity by git push --dry-run <repositoryUrl>
. And they will use gitUrlParse
to get the repositoryURL
.
However, the repositoryURL
your current version return is like https://[secure]@companyname.visualstudio.com/DefaultCollection/MyRepo
, the correct repositoryURL
for us on VSTS is https://[secure]@companyname.visualstudio.com/DefaultCollection/_git/MyRepo
.
The error that we had is like:
fatal: Authentication failed for 'https://[secure]@companyname.visualstudio.com/DefaultCollection/MyRepo.git/
2018-04-10T12:00:43.9886799Z { SemanticReleaseError: The push permission to the Git repository is required.
2018-04-10T12:00:43.9903773Z at module.exports (/vsts/agent/_work/1/s/node_modules/semantic-release/lib/get-error.js:6:10)
2018-04-10T12:00:43.9922450Z at run (/vsts/agent/_work/1/s/node_modules/semantic-release/index.js:51:11)
2018-04-10T12:00:43.9940073Z at <anonymous>
2018-04-10T12:00:43.9956623Z at process._tickCallback (internal/process/next_tick.js:188:7)
2018-04-10T12:00:43.9973157Z name: 'SemanticReleaseError',
2018-04-10T12:00:43.9990080Z code: 'EGITNOPERMISSION',
2018-04-10T12:00:44.0008210Z details: '**semantic-release** cannot push the version tag to the branch `BUILD` on remote Git repository.\n\nPlease refer to the [authentication configuration documentation](https://github.com/semantic-release/semantic-release/blob/caribou/docs/usage/ci-configuration.md#authentication) to configure the Git credentials on your CI environment.',
2018-04-10T12:00:44.0027178Z semanticRelease: true }
and the URL that we need is https://[secure]@companyname.visualstudio.com/DefaultCollection/_git/MyRepo
This issue happen at your version (8.3.1) with semantic-release
version (15.1.5)
I ran some valid and invalid URLs from Github's URL Normalization tests (link here) and for cases that are fully invalid (such as scheme://invalid....:[
or ://acme.co
) i am getting valid parsing.
values.scm_url
is the string value we give GitUrlParse()
and parsed
is the resulting output for those cases.
I'm logging this issues on Google Chrome version 98.0.4758.80 and node v12.7.0
Examples:
Return for scheme://invalid....:[
filepathtype: ""
full_name: "["
git_suffix: false
hash: ""
href: "scheme://invalid....:["
name: "["
organization: ""
owner: ""
pathname: "/["
port: null
protocol: "ssh"
protocols: ['scheme']
query: {}
ref: ""
resource: "invalid...."
search: ""
source: "..."
toString: ƒ (type)
token: ""
user: ""
Return for ://acme.co
filepath: ""
filepathtype: ""
full_name: "://acme.co"
git_suffix: false
hash: ""
href: "://acme.co"
name: "acme.co"
organization: ":/"
owner: ":/"
pathname: "://acme.co"
port: null
protocol: "file"
protocols: []
query: {}
ref: ""
resource: ""
search: ""
source: ""
toString: ƒ (type)
token: ""
user: ""
const gitUrlParse = require("..");
gitUrlParse(' http://github.com/IonicaBizau/git-url-parse ');
/*
{ protocols: [ ' http' ],
protocol: ' http',
port: null,
resource: 'github.com',
user: '',
pathname: '/IonicaBizau/git-url-parse ',
hash: '',
search: '',
href: ' http://github.com/IonicaBizau/git-url-parse ',
token: '',
toString: [Function],
source: 'github.com',
name: 'git-url-parse ',
owner: 'IonicaBizau',
git_suffix: false,
ref: '',
filepathtype: '',
filepath: '',
organization: 'IonicaBizau',
full_name: 'IonicaBizau/git-url-parse ' }
*/
Parsing a URL with extra spaces result in wrong properties for protocols
, protocol
, pathname
, name
, href
and full_name
.
I'd like to propose a PR to trim the URL passed to the parser. However I'm not sure if you prefer to do that in git-url-parse
, git-up
, parse-url
or parse-path
.
I would imagine parse-path
is the right place? Unless spaces are allowed at the beginning and end of path? I know they are not significant in URLs but not sure about FileSystem paths.
FTP(S) URLs are incorrectly stringified as SSH URLs.
The latest update fails when trying to parse URLs like: http://machine:8080/tfs/Collection/Project.Name/_git/repository
The error is caused by the parse-url library:
TypeError: Cannot read property 'domain' of null at gitUrlParse (D:\Dev\i4\i4-common\node_modules\git-url-parse\lib\index.js:51:37)
GitHub Enterprise repositories doesn't use the git
username in SSH urls, and can look like this:
[email protected]:squareup/repo-name.git
When parsed, it seems to include the username in the owner
, organization
, full_name
properties:
{
protocols: [ 'file' ],
protocol: 'file',
port: '',
resource: '',
user: '',
password: '',
pathname: '',
hash: '',
search: '',
href: '[email protected]:squareup/repo-name.git',
query: {},
token: '',
toString: [Function (anonymous)],
source: '',
git_suffix: false,
name: 'repo-name',
owner: '[email protected]:squareup',
commit: undefined,
ref: '',
filepathtype: '',
filepath: '',
organization: '[email protected]:squareup',
full_name: '[email protected]:squareup/repo-name'
}
This is affecting lerna's ability to publish to GitHub Enterprise repositories.
If we want to parse the url and use it as a hyperlink, e.g <a href="">
, current way of parsing and stringify the url still leaves .git
as suffix
GitUrlParse("[email protected]:IonicaBizau/node-git-url-parse.git").toString("https")
// => "https://github.com/IonicaBizau/node-git-url-parse.git"
// but it would be cleaner if it's just "https://github.com/IonicaBizau/node-git-url-parse"
Can we add an option to omit the .git
when using .toString()
? And if not, what would be the reason for not implementing it? Happy to submit a PR for it
Stringify methond ignores token
field.
const GitUrlParse = require("git-url-parse");
const url = '[email protected]:user/repo.git';
const obj = GitUrlParse(url);
obj.token = 'token';
GitUrlParse.stringify(obj, 'https');
// we get "https://github.com/user/repo"
// bug e.g. for github expected is "https://[email protected]/user/repo"
From #10 I know that token format differs across providers.
So the possible way to fix this is to have switch
based on source
field. And if source
is neither github.com
nor bitbucket.com
and token
field is present then throw an error (currently it just silently ignores token which leads to bugs).
Maybe you can come up with some better way to fix this. If not I will send a PR
Not sure what to do about this one...
A typical github.com SSH url is something like [email protected]:user/repo.git
. If the user
is a number, then it gets parsed as a port. The problem is that GitHub has users whose names are just numbers.
Parsing that number as a port makes sense in every context unless we know that it's a GitHub (or GitHub Enterprise) URL. GitHub doesn't allow SSH over any port except 22, and GitHub Enterprise doesn't either (it's not configurable by the admin). They probably do this specifically to avoid this issue; if the port can't be anything but 22, then the URL format is no longer ambiguous; that thing after a colon is always a user name.
Not sure what to do about this. For github.com
you could probably add a bunch of logic to git-url-parse
after you get it back from git-up
and see that the domain is github.com
... it would involve doing really heavy surgery on the object to fix it up, but it's technically possible. That doesn't solve the problem for Enterprise URLs though, and I don't see how that's solvable without being able to pass options to git-url-parse
.
Great little utility you have here! It'd be nice if it handled non-GitHub providers a little better. For instance, with Bitbucket, HTTPS URL's take the form of https://<owner>@bitbucket.org/<owner>/<name>
, which results in a incorrect value for source
of <owner>@bitbucket.org
.
Hello,
I tried parsing an Azure DevOps url and found out that the filepath is not set, even though it is present as a query parameter.
GitUrlParse('https://dev.azure.com/organization/project/_git/repo?path=%2Ffolder%2Ffile.ext')
gives the following:
{
protocols: [ 'https' ],
protocol: 'https',
port: null,
resource: 'dev.azure.com',
user: '',
pathname: '/organization/project/_git/repo',
hash: '',
search: 'path=%2Ffolder%2Ffile.ext',
href: 'https://dev.azure.com/organization/project/_git/repo?path=%2Ffolder%2Ffile.ext',
query: [Object: null prototype] { path: '/folder/file.ext' },
token: '',
toString: [Function],
source: 'azure.com',
git_suffix: false,
name: 'repo',
owner: 'project',
organization: 'organization',
full_name: 'organization/project/_git/repo'
}
I would like the filepath property to be set to folder/file.ext
in this case.
Since the update to version 12.0.0, parsing a URI like git://github.com:user/repo
returns the following incorrect output:
{
protocols: [ 'file' ],
protocol: 'file',
port: '',
resource: '',
user: '',
password: '',
pathname: '',
hash: '',
search: '',
href: 'git://github.com:user/repo',
query: {},
token: '',
toString: [Function (anonymous)],
source: '',
git_suffix: false,
name: 'repo',
owner: 'git://github.com:user',
commit: undefined,
ref: '',
filepathtype: '',
filepath: '',
organization: 'git://github.com:user',
full_name: 'git://github.com:user/repo'
}
This breaks functionality in projects such as release-it.
Is this intended behavior?
Thank you
npm test
command fails on Windows 10 with node 8.
Error:
$ npm test
> [email protected] test C:\Users\Gyandeep\WebstormProjects\git-url-parse
> node test
C:\Users\Gyandeep\WebstormProjects\git-url-parse\node_modules\emoji-logger\lib\index.js:74
throw new Err("There is no such icon: " + icon, "NO_SUCH_ICON");
^
Error: There is no such icon: heavyCheckMark
at new Err (C:\Users\Gyandeep\WebstormProjects\git-url-parse\node_modules\err\lib\index.js:19:17)
at Function.emojiLogger.add (C:\Users\Gyandeep\WebstormProjects\git-url-parse\node_modules\emoji-logger\lib\index.js:74:15)
at Object.<anonymous> (C:\Users\Gyandeep\WebstormProjects\git-url-parse\node_modules\emoji-logger\lib\index.js:88:13)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
Hi, @IonicaBizau
Thanks for the great library! I noticed that an example from README does not work as expected in 10.1.0
version of the library:
> const GitUrlParse = require("git-url-parse");
> GitUrlParse("[email protected]:IonicaBizau/node-git-url-parse.git").toString("https")
'https://[email protected]/:IonicaBizau/node-git-url-parse.git'
while in README the result is:
'https://github.com/IonicaBizau/node-git-url-parse.git'
In case I'm not aware of internal API change, how is it possible to conver an ssh
url to https
one?
Hi,
I get different results with Bitbucket Server URL in case of https and ssh.
HTTPS:
var gitUrlParse = require("git-url-parse")
const parsed = gitUrlParse("https://[email protected]:8443/bitbucket/scm/lpbran/testrepo1.git");
Object
organization: "bitbucket/scm/lpbran"
owner: "bitbucket/scm/lpbran"
SSH:
var gitUrlParse = require("git-url-parse")
const parsed = gitUrlParse("ssh://[email protected]:7999/lpbran/testrepo1.git");
Object
organization: "lpbran"
owner: "lpbran"
Thank you and kind regards,
pII
With 2 elements in the path:
GitUrlParse("[email protected]:a/b.git");
{ protocols: [],
protocol: 'ssh',
port: null,
resource: 'github.com',
user: 'git',
pathname: '/a/b.git',
hash: '',
search: '',
href: '[email protected]:a/b.git',
token: '',
toString: [Function],
source: 'github.com',
name: 'b',
owner: 'a',
organization: 'git',
full_name: 'a/b' }
Everything seems correct except the organization
that is set to git
.
With more than 2 elements in the path:
GitUrlParse("[email protected]:a/b/c/d.git");
{ protocols: [],
protocol: 'ssh',
port: null,
resource: 'github.com',
user: 'git',
pathname: '/a/b/c/d.git',
hash: '',
search: '',
href: '[email protected]:a/b/c/d.git',
token: '',
toString: [Function],
source: 'github.com',
name: 'a/b/c/d',
owner: 'git',
organization: 'git',
full_name: 'git/a/b/c/d' }
The name
, owner
, organization
and full_name
are wrong.
This type of URL are valid for GitLab repositories in a sub-group: https://docs.gitlab.com/ee/user/group/subgroups/index.html
https://github.com/owner/repo/issues
returns returns owner/repo
as the owner, and issues
as the repo name.
Example: https://github.com/scazzy/CSS-FORM-UI/issues
returns scazzy/CSS-FORM-UI
as owner, and issues
as repo name.
const gitUrlParse = require('git-url-parse');
gitUrlParse('[email protected]:IonicaBizau/node-git-url-parse.git').toString();
// => [email protected]:IonicaBizau/node-git-url-parse
// => Should be [email protected]:IonicaBizau/node-git-url-parse.git
gitUrlParse('https://github.com/IonicaBizau/node-git-url-parse.git').toString();
// => https://github.com/IonicaBizau/node-git-url-parse
// => Should be https://github.com/IonicaBizau/node-git-url-parse.git
It seems to be due to the parsing that doesn't set git_suffix
to true
when the URL ends with .git
:
> gitUrlParse('https://github.com/IonicaBizau/node-git-url-parse.git')
/*
{ protocols: [ 'https' ],
protocol: 'https',
port: null,
resource: 'github.com',
user: '',
pathname: '/IonicaBizau/node-git-url-parse.git',
hash: '',
search: '',
href: 'https://github.com/IonicaBizau/node-git-url-parse.git',
token: '',
toString: [Function],
source: 'github.com',
name: 'node-git-url-parse',
owner: 'IonicaBizau',
git_suffix: false,
ref: '',
filepathtype: '',
filepath: '',
organization: 'IonicaBizau',
full_name: 'IonicaBizau/node-git-url-parse' }
*/
if there's a /
in revision name (either for tag
or branch
) then url is parsed in a wrong manner and cuts the revision name from the existing /
. so for e.g if branch name is feature/foo
then git-url-parse would fetch the revision name as feature
leaving /foo
out.
e.g. git+ssh://[email protected]/IonicaBizau/node-giturparse.git
Seems to be an issue with stringify
removing sub-folders from a parsed repo url (v8.0.1):
const url = GitUrlParse("https://www.example.com/tripleaxis/node/myproject.git").toString('https');
console.log(url);
// expected: 'https://www.example.com/tripleaxis/node/myproject.git'
// output: 'https://www.example.com/tripleaxis/node'
It seems the full_name
property is being used in the reconstruction instead of pathname
.
This release still depends on normalize-url@^6.1.0
, which is the version not support Safari. Maybe parse-url
should update it's dependence to normalize-url@^7
.
The code below make website crash in safari.
Originally posted by @lianghx-319 in #138 (comment)
var gitUrlParse = require("git-url-parse")
var parsed = gitUrlParse("[email protected]:my-org/my-repo.git")
for (var key in parsed) {
console.log(key, parsed[key])
}
yields owner :my-org
vs owner my-org
Repro:
const GitUrlParse = require("git-url-parse");
const a = GitUrlParse("[email protected]:0xABCDEF/myreponame.git");
const b = GitUrlParse("[email protected]:1xABCDEF/myreponame.git");
const c = GitUrlParse("[email protected]:zxABCDEF/myreponame.git");
console.log(a.owner, a.full_name); // BUGGY => git git/myreponame
console.log(b.owner, b.full_name); // OK => 1xABCDEF 1xABCDEF/myreponame
console.log(c.owner, c.full_name); // OK => zxABCDEF zxABCDEF/myreponame
I have a git url to parse where the owner's GitHub user name is a hexadecimal number. :-)
Checking a Git url that is using OAuth returns an incorrect source. The format for an OAuth url in GitHub is https://<token>:[email protected]/<owner>/<name>.git
and returns a source of <token>:[email protected]
instead of just github.com
.
result source is com.cn
, maybe should test.com.cn
.
If a protocol is listening on a port, we can safely assume any other protocol will not be.
I fixed it in the 3rd line of stringify with:
var port = (obj.port && type === obj.protocol) ? ":" + obj.port : '';
Useful when converting to http(s)
Following the issues IonicaBizau/parse-url#19 and IonicaBizau/git-up#24, git-url-parse
should have an updated version of git-up
to fix the vulnerability.
Two versions to verify:
[email protected]
uses [email protected]
that uses [email protected]
, and [email protected]
does not seem to be compatible with Safari.[email protected]
only requires [email protected]
which seems to be OK with Safari. See if git-up
could have another version that uses [email protected]
.Details about the security issue: https://www.npmjs.com/advisories/1755
OS: Windows 10 Home, using "bash" (Windows Subsystem for Linux).
call:
gitUrlParse('[email protected]:IonicaBizau/node-git-url-parse.git')
pathName returned:
pathname: '/:IonicaBizau/node-git-url-parse.git'
it puts ":" after first / in pathname
EDIT:
it seems not to happen running your "example" project.
I'll close this issue for now.
EDIT 2: I had v10 of the library. Resolved with 11.1.2
OS: Windows 7
Node: 8.0.1
Version: 6.2.2
CLI: git bash
console.log(GitUrlParse("[email protected]:IonicaBizau/node-git-url-parse.git").toString("https"));
// => "https://github.com/IonicaBizau/node-git-url-parse"
console.log(GitUrlParse("https://github.com/IonicaBizau/node-git-url-parse.git").toString("https"));
// => "https://github.com/IonicaBizau/node-git-url-parse"
I am using the code from the example from README.
I can work on the fix if you agree that this is a bug.
Hi,
I have a Bitbucket Server HTTPS clone URL.
But the Protocol is SSH in the result.
In this case user is the username from username:password@ for basic auth.
var gitUrlParse = require("git-url-parse")
const parsed = gitUrlParse("https://[email protected]:8443/bitbucket/scm/lpbran/testrepo1.git");
Object
commit: undefined
filepath: ""
filepathtype: ""
full_name: "bitbucket/scm/lpbran/testrepo1"
git_suffix: true
hash: ""
href: "https://[email protected]:8443/bitbucket/scm/lpbran/testrepo1.git"
name: "testrepo1"
organization: "bitbucket/scm/lpbran"
owner: "bitbucket/scm/lpbran"
pathname: "/bitbucket/scm/lpbran/testrepo1.git"
port: 8443
protocol: "ssh"
protocols: ["https"]
query: Object {}
ref: ""
resource: "servername.org"
search: ""
source: "servername.org"
toString: function()
token: ""
user: "user"
Thank you and kind regards,
pII
We need to specify x-oauth-basic when we use a GitHub Personal Access Token.
The format for an OAuth url in GitHub is https://<token>:[email protected]/<owner>/<name>.git
.
I think we should add a case for github.com
to return <token>:x-oauth-basic@
.
Lines 272 to 279 in 71c7298
Related to #10
Hey there! I'm looking into using this for the Binder project running at mybinder.org, we need to parse URLs for git repositories and determine if they're a github repo / gist / gitlab repo / etc. It seems that this gets quite close! However, we need to be able to determine a reference as well as the repo information (e.g. a branch name). Am I right in thinking this doesn't currently work w/ git-url-parse
?
E.g., this works:
GitUrlParse("https://gitlab.com/fdroid/fdroidclient")
OUT:
{ protocols: [ 'https' ],
protocol: 'https',
port: null,
resource: 'gitlab.com',
user: '',
pathname: '/fdroid/fdroidclient',
hash: '',
search: '',
href: 'https://gitlab.com/fdroid/fdroidclient',
token: '',
toString: [Function],
source: 'gitlab.com',
name: 'fdroidclient',
owner: 'fdroid',
organization: '',
full_name: 'fdroid/fdroidclient' }
whereas this seems to trip up a bit:
GitUrlParse("https://gitlab.com/fdroid/fdroidclient/tree/stable-v0.102")
OUT:
{ protocols: [ 'https' ],
protocol: 'https',
port: null,
resource: 'gitlab.com',
user: '',
pathname: '/fdroid/fdroidclient/tree/stable-v0.102',
hash: '',
search: '',
href: 'https://gitlab.com/fdroid/fdroidclient/tree/stable-v0.102',
token: '',
toString: [Function],
source: 'gitlab.com',
name: 'fdroid/fdroidclient/tree/stable-v0.102',
owner: '',
organization: '',
full_name: 'fdroid/fdroidclient/tree/stable-v0.102' }
Have you given any thoughts to this usecase?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.