Skip to content

Commit

Permalink
Add the host and update the parse-path.
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Jul 25, 2022
1 parent ff27e1b commit 0790043
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import parsePath from "parse-path";
import normalizeUrl from "normalize-url";


/**
* parseUrl
* Parses the input url.
Expand Down Expand Up @@ -63,6 +62,7 @@ const parseUrl = (url, normalize = false) => {
parsed.protocols = ["ssh"]
parsed.protocol = "ssh"
parsed.resource = matched[4]
parsed.host = matched[4]
parsed.user = "git"
parsed.pathname = `/${matched[6]}`
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"tester": "^1.3.1"
},
"dependencies": {
"parse-path": "^5.0.0",
"normalize-url": "^7.0.3"
"normalize-url": "^7.0.3",
"parse-path": "^6.0.0"
},
"files": [
"bin/",
Expand All @@ -55,4 +55,4 @@
"For low-level path parsing, check out [`parse-path`](https://github.com/IonicaBizau/parse-path). This very module is designed to parse urls. By default the urls are normalized."
]
}
}
}
7 changes: 7 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const INPUTS = [
, protocol: "http"
, port: ""
, resource: "ionicabizau.net"
, host: "ionicabizau.net"
, user: ""
, pathname: "/blog"
, hash: ""
Expand All @@ -25,6 +26,7 @@ const INPUTS = [
, protocol: "http"
, port: ""
, resource: "ionicabizau.net"
, host: "ionicabizau.net"
, user: ""
, pathname: "/foo.js"
, hash: ""
Expand All @@ -39,6 +41,7 @@ const INPUTS = [
, protocol: "http"
, port: ""
, resource: "domain.com"
, host: "domain.com"
, user: ""
, pathname: "/path/name"
, hash: "some-hash?foo=bar"
Expand All @@ -53,6 +56,7 @@ const INPUTS = [
, protocol: "git"
, port: ""
, resource: "host.xz"
, host: "host.xz"
, user: "git"
, pathname: "/path/name.git"
, hash: ""
Expand All @@ -67,6 +71,7 @@ const INPUTS = [
, protocol: "ssh"
, port: ""
, resource: "github.com"
, host: "github.com"
, user: "git"
, pathname: "/IonicaBizau/git-stats.git"
, hash: ""
Expand All @@ -81,6 +86,7 @@ const INPUTS = [
, protocol: "http"
, port: ""
, resource: "ionicabizau.net"
, host: "ionicabizau.net"
, user: ""
, pathname: "/with-true-normalize"
, hash: ""
Expand All @@ -95,6 +101,7 @@ const INPUTS = [
, protocol: "file"
, port: ""
, resource: ""
, host: ""
, user: ""
, pathname: "/etc/passwd"
, hash: "http://a:1:1"
Expand Down

0 comments on commit 0790043

Please sign in to comment.