good-blender

1.0.2 • Public • Published

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

what more examples?

Checkout the tests!

Package Sidebar

Install

npm i good-blender

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

11.6 kB

Total Files

4

Last publish

Collaborators

  • caseygoodhew