Node | urlObject.hash API
Before we go on to learn about URL objects API we need to know a brief about URL.
If you ever wanted to provide utilities so as to parse or resolute your URL, we can do it through the URL Module.
We can divide the URL Module into two parts:- These are- URL String and URL Object. The urlObjectHash is a part of URL Object which is generally based on Legacy API (Though a newer API is also provided by the name of WHATWG URL Standard)
urlObject.hash: It is used for identifying the “fragment” portion of a URL. This property also includes the # character.
For example: '#hash'.
Syntax
urlObject.hash
Example:
const url = require('url'); const reqUrl = 'www.example.com/hi#file?=newFile'const urlObject = url.parse(reqUrl, true); console.log(urlObject.hash); |
OUTPUT:
#file?=newFile
Recommended Posts:
- Why Node.js ?
- Node js | OS
- Node | URL.password API
- Promises in Node.js
- Node | URL.pathToFileURL API
- Node | URL.fileURLToPath API
- Node | URLSearchParams.set()
- Node | URL.resolve(from,to) API
- Node | URL.search API
- Node | URL.username API
- Node | URL.port API
- Routing in Node.js
- Node | URL.origin API
- Node | URL.host API
- Node | URL.hostname API
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



