Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Refactor codebase, update dependencies
  • Loading branch information
IonicaBizau committed Jun 27, 2022
1 parent 2cd6eba commit 86bd682
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 87 deletions.
15 changes: 7 additions & 8 deletions lib/index.js
Expand Up @@ -26,24 +26,23 @@ const parseUrl = require("parse-url")
* - `token` (String): The oauth token (could appear in the https urls).
*/
function gitUp(input) {
if (input.includes("token")) debugger
let output = parseUrl(input);
output.token = "";

let splits = output.user.split(":");
if (splits.length === 2) {
if (splits[1] === "x-oauth-basic") {
output.token = splits[0];
} else if (splits[0] === "x-token-auth") {
output.token = splits[1];
}
if (output.password === "x-oauth-basic") {
output.token = output.user;
} else if (output.user === "x-token-auth") {
output.token = output.password
}

if (isSsh(output.protocols) || isSsh(input)) {
if (isSsh(output.protocols) || (output.protocols.length === 0 && isSsh(input))) {
output.protocol = "ssh";
} else if (output.protocols.length) {
output.protocol = output.protocols[0];
} else {
output.protocol = "file";
output.protocols = ["file"]
}

output.href = output.href.replace(/\/$/, "")
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -27,8 +27,8 @@
},
"homepage": "https://github.com/IonicaBizau/git-up",
"dependencies": {
"is-ssh": "^1.3.0",
"parse-url": "^6.0.0"
"is-ssh": "^1.4.0",
"parse-url": "^7.0.2"
},
"devDependencies": {
"tester": "^1.4.3"
Expand Down

0 comments on commit 86bd682

Please sign in to comment.