All browsers that support modules also support the URL API, so I don't see any reason to use the <a> tag just to convert a relative URL to an absolute one.
Your toAbsoluteURL() function could be removed and you could update the usage as follows:
- const absURL = toAbsoluteURL(url);
+ const absURL = new URL(url, location).href;
All browsers that support modules also support the URL API, so I don't see any reason to use the
<a>tag just to convert a relative URL to an absolute one.Your
toAbsoluteURL()function could be removed and you could update the usage as follows: