Nearby lessons
12 of 21🌐 URL Module in Node.js
📌 What is URL?
What is a URL?
- A URL (Uniform Resource Locator) is the address of a unique resource on the internet.
- It is used by browsers to retrieve resources such as HTML pages, CSS files, images, etc.
- Each valid URL points to a unique resource.
Hash Sign and Fragment
- A hash sign (
#) in a URL is referred to as a fragment. - URL fragments historically set the browser's scroll position to a predefined location on a page.
- If a URL refers to a document, the fragment refers to a specific subsection.
The Built-in URL Module in Node.js
- The URL module splits a web address into readable parts.
- It provides utilities for parsing and resolving URLs.
- Parsing converts an unstructured string into a structured object that's easier to work with.
📝 Example 1 - Parse a Static URL
Example02
Loading editor…
📝 Example 2 - Access URL Parts
Example03
Loading editor…
📝 Example 3 - Log Request URL in Server
Example04
Loading editor…
📝 Example 4 - Parse Request URL in Server
Example05
Loading editor…