Skip to content

Request: Validate if string is clonable #166

Open
@TheJaredWilcurt

Description

@TheJaredWilcurt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions