Blender
Blender resolves relative urls.
installation
$ npm install good-blender
usage
const blender = require('good-blender');
const relative = '/api';
const context = 'http://mysite.com/homepage';
console.log(blender(relative, context)); // http://mysite.com/api
blender('/api', 'http://c.d/test/status'); // http://c.d/api
blender('api', 'http://c.d/test/status'); // http://c.d/test/status/api
blender('./api', 'http://c.d/test/status'); // http://c.d/test/status/api
blender('../api', 'http://c.d/test/status'); // http://c.d/test/api
blender('../api', 'http://c.d/test'); // http://c.d/api
blender('../../api', 'http://c.d/test'); // http://c.d/api
blender('/api', 'http://c.d?query'); // http://c.d/api
blender('/api?query', 'http://c.d'); // http://c.d/api?query
blender('/api?query', 'http://c.d?nop'); // http://c.d/api?query
blender('/api', 'http://c.d#hash'); // http://c.d/api
blender('/api#hash', 'http://c.d#nop'); // http://c.d/api#hash
blender('/api#hash', 'http://c.d'); // http://c.d/api#hash
blender('http://a.b/api', 'http://c.d'); // http://a.b/api