Node.js Project to Parse Website URLs (Git) Links Using parse-url Library in Javascript Full Tutorial For Beginners

Node.js Project to Parse Website URLs (Git) Links Using parse-url Library in Javascript Full Tutorial For Beginners

 

Welcome folks today in this blog post we will be looking at how to parse website urls also supports git links using parse-urllibrary in javascript. All the full source code of application is shown below.

 

 

 

 

Get Started

 

 

 

 

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

 

index.js

 

 

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

 

node index.js

 

 

 

 

So as you can see it prints out different information regarding the domain such as path, port and protocol etc.

See also  Build a jQuery Fake Login Page in Browser Using HTML5 CSS3 and Vanilla Javascript Full Project For Beginners

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 "file".
  • 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.

 

Leave a Reply