Narrating Prophetic Monks
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

urel

1.0.0 • Public • Published

urel

Get the relative URL between two root-relative URLs.

Setup

If you use a module bundler like Browserify, you can install urel with npm.

In your project root:

npm install urel --save

In one of your application modules:

var relative = require('urel');

Examples

See the test.js module for more details on what to expect. Here are a few examples.

relative('/common/dir/foo.html', '/common/dir/bar.html'); // './bar.html'
relative('/common/dir/foo.html', '/common/bar.html');     // '../bar.html'
relative('/common/foo.html', '/common/dir/bar.html');     // './dir/bar.html'

Note that this module currently only works with root-relative URLs (e.g. '/example/path.html') and not absolute URLs (e.g. 'http://example.com/example/path.html'). If you'd like to see it work with absolute URLs, please submit a pull request.

Build Status

Keywords

install

npm i urel

Downloadsweekly downloads

11

version

1.0.0

license

MIT

last publish

collaborators

  • avatar