Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Validate if string is clonable #166

Open
TheJaredWilcurt opened this issue Feb 17, 2024 · 1 comment
Open

Request: Validate if string is clonable #166

TheJaredWilcurt opened this issue Feb 17, 2024 · 1 comment

Comments

@TheJaredWilcurt
Copy link

TheJaredWilcurt commented Feb 17, 2024

Just a simple boolean to say if the string passed in can be used with git clone.

Since there is so much variety in what is allowed:

I'd rather offload this check to a more well tested library than doing a naive approach of just checking if it ends in .git and starts with https:// or git@, which wouldn't actually be accurate.

I assume the existing parsed object could just have isClonable: true or isClonable: false appended to the result.

const GitUrlParse = require("git-url-parse");

console.log(GitUrlParse("[email protected]:IonicaBizau/node-git-url-parse.git"));
// => {
//     isClonable: true,
//   , protocols: []
//   , port: null
//   , resource: "github.com"
//   , user: "git"
//   , pathname: "/IonicaBizau/node-git-url-parse.git"
//   , hash: ""
//   , search: ""
//   , href: "[email protected]:IonicaBizau/node-git-url-parse.git"
//   , token: ""
//   , protocol: "ssh"
//   , toString: [Function]
//   , source: "github.com"
//   , name: "node-git-url-parse"
//   , owner: "IonicaBizau"
// }

But would also be fine with it being an appended method, like .toString().

GitUrlParse("[email protected]:IonicaBizau/node-git-url-parse.git").isClonable(); // true
@IonicaBizau
Copy link
Owner

The problem with this is that we can't know if it is clonable unless we actually make a request to the URL. Technically, I believe any url could eventually serve back a git repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants