1.0.0 • Published 10 years ago
urel v1.0.0
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 --saveIn 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.
1.0.0
10 years ago