URL Resolution Lab

Medium
12
52.0% Acceptance

In this lab, you will be using the built-in url module of Node.js to resolve and transform URLs with different base URLs and relative URLs. The url.resolve() method is used to resolve a base URL and a relative URL into an absolute URL. The method takes two arguments: the base URL and the relative URL. The result will be a new absolute URL constructed from the two input URLs.

For example, if you have a base URL https://example.com/a/b/c/ and the relative URL ../d/e/f, the resulting URL will be https://example.com/a/b/d/e/f.

In this lab, you will create a Node.js module that exports the following functions:

  1. resolveAbsoluteURL: A function that takes a base URL and a relative URL as its parameters and returns the resolved absolute URL using the url.resolve() method.

  2. customURLResolver: A higher-order function which, when called with a base URL, returns a new function. The new function accepts only the relative URL and returns the resolved absolute URL.

Remember to use ESM (ECMAScript Module) syntax for importing and exporting modules.

Challenges

  1. Export resolveAbsoluteURL function.
  2. Export customURLResolver function.
  3. resolveAbsoluteURL function should correctly resolve the absolute URL.
  4. customURLResolver function should return a new function that resolves the absolute URL correctly.