How to resolve relative path to absolute url in ES6 module (in browser)?
For example :
base-url.com/
|-resolve
| |-resolveUrl.js
|-dir
|-dir1
|-module1.js
|-dir2
|-module2.js
module1.js
import resolveUrl from "../../../resolve/resolveUrl.js"
resolveUrl("../dir2/module2.js") // return 'base-url.com/dir/dir2/module2.js'
What would be the resolveUrl
implementation?
base-url.com/
may not be the web-site's domain. It can be a repo where only sources are stored.