Bird
0
0

Given base URL 'https://example.com/dir1/dir2/' and relative URL '../dir3/file.txt', what is the resolved absolute URL?

hard📝 Application Q9 of 15
Node.js - URL and Query String Handling
Given base URL 'https://example.com/dir1/dir2/' and relative URL '../dir3/file.txt', what is the resolved absolute URL?
Ahttps://example.com/dir3/file.txt
Bhttps://example.com/dir1/dir2/dir3/file.txt
Chttps://example.com/dir1/dir3/file.txt
Dhttps://example.com/dir1/dir2/file.txt
Step-by-Step Solution
Solution:
  1. Step 1: Understand base URL path

    The base path is '/dir1/dir2/'.
  2. Step 2: Apply '../' to move up one directory

    Moving up one directory from '/dir1/dir2/' leads to '/dir1/'.
  3. Step 3: Append 'dir3/file.txt'

    Appending results in '/dir1/dir3/file.txt'.
  4. Final Answer:

    https://example.com/dir1/dir3/file.txt -> Option C
  5. Quick Check:

    One '..' moves up one folder = C [OK]
Quick Trick: One '..' moves up one directory in URL paths [OK]
Common Mistakes:
  • Appending without moving up
  • Confusing directory levels

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes