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?
✗ Incorrect
An absolute URL includes the protocol and domain, like 'https://site.com/page'.
In Node.js, which object helps resolve relative URLs against a base URL?
✗ Incorrect
The URL constructor in Node.js resolves relative URLs against a base URL.
If the base URL is 'https://example.com/folder/' and the relative URL is '../file.txt', what is the resolved absolute URL?
✗ Incorrect
The '..' moves one folder up, so the file is at 'https://example.com/file.txt'.
Which URL type is best to use when linking to resources within the same website?
✗ Incorrect
Relative URLs are easier to maintain within the same site and adapt if the domain changes.
What happens if you use an absolute URL in your code and the domain changes?
✗ Incorrect
Absolute URLs hardcode the domain, so if it changes, links break unless updated.
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.