Welcome folks today in this blog post we will be looking at how to parse
website urls also supports git links using
In order to get started you need to install the
parse-url library by issuing the npm command
npm i parse-url
After installing it make an
index.js file and copy paste the following code
const parseUrl = require("parse-url") console.log(parseUrl("http://ionicabizau.net/blog"))
Here in this block of code we are first of all including the library and then we are providing a unique
website url to the method to parse a
url and if you execute this node.js
script by issuing the following command
So as you can see it prints out different information regarding the domain such as
This is the list of information it returns inside a object
protocols(Array): An array with the url protocols (usually it has one element).
protocol(String): The first protocol,
"ssh"(if the url is a ssh url) or
port(null|Number): The domain port.
resource(String): The url domain (including subdomains).
user(String): The authentication user (usually for ssh urls).
pathname(String): The url pathname.
hash(String): The url hash.
search(String): The url querystring value.
href(String): The input url.
query(Object): The url querystring, parsed as object.