Create a relative URL with minify options.
http://domain.com/dir1/dir1-1/ as a base URL, you can produce:
>= 6 is required. To install, type this at the command line:
npm install relateurl
Inputs must be
const relateURL = require('relateurl'); const base = new URL('http://domain.com/dir1/dir1-1/'); const url = new URL('//domain.com/dir1/dir1-2/index.html', base); relateURL(url, base, options); //-> ../dir1-2/
It is simplest to use an option profile, but custom configurations are still possible.
Type: constant /
The limit of how far the resulting URL should be related. Possible values:
PROTOCOL_RELATIVE: will try to produce something like
ROOT_PATH_RELATIVE: will try to produce something like
PATH_RELATIVE: will try to produce something like
SHORTEST: will try to choose whichever is shortest between
Any other defined option will be passed to minurl. Avoid setting
false, as it will prevent any operations performed by this library from being outputted.
There're two profiles: