0
0
Node.jsframework~5 mins

Relative vs absolute URL resolution in Node.js - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What is an absolute URL?
An absolute URL is a full web address that includes the protocol (like http:// or https://), domain name, and the full path to a resource. It points to the exact location on the internet.
Click to reveal answer
beginner
What is a relative URL?
A relative URL points to a resource based on the current page's location. It does not include the domain or protocol, just the path relative to where you are.
Click to reveal answer
intermediate
How does Node.js resolve a relative URL against a base URL?
Node.js uses the URL constructor to combine a relative URL with a base absolute URL, producing a full absolute URL by filling in missing parts from the base.
Click to reveal answer
beginner
Example: What is the absolute URL of 'images/photo.jpg' if the base URL is 'https://example.com/gallery/'?
The absolute URL is 'https://example.com/gallery/images/photo.jpg'. The relative path is added to the base URL's path.
Click to reveal answer
beginner
Why is understanding relative vs absolute URLs important in web development?
It helps in correctly linking resources like images, scripts, and pages. Using the right URL type ensures links work no matter where the site is hosted or moved.
Click to reveal answer
Which of the following is an absolute URL?
A../page
B/page
Cpage.html
Dhttps://site.com/page
In Node.js, which object helps resolve relative URLs against a base URL?
AHttp
BPath
CURL
DFs
If the base URL is 'https://example.com/folder/' and the relative URL is '../file.txt', what is the resolved absolute URL?
Ahttps://example.com/file.txt
Bhttps://example.com/folder/file.txt
Chttps://example.com/folder/../file.txt
Dhttps://example.com/folder/../folder/file.txt
Which URL type is best to use when linking to resources within the same website?
AAbsolute URL
BRelative URL
CBoth are equally good
DNeither
What happens if you use an absolute URL in your code and the domain changes?
ALinks break because they point to the old domain
BLinks automatically update
CLinks become relative
DNothing changes
Explain the difference between relative and absolute URLs and how Node.js resolves them.
Think about how a relative path is combined with a base full address.
You got /4 concepts.
    Describe a real-life scenario where choosing between relative and absolute URLs matters in a web project.
    Consider what happens if you move your website to a new address.
    You got /4 concepts.