resolve-relative-url
v1.0.0
Published
Resolve a possibly relative URL agains a source URL
Downloads
26,091
Readme
resolve-relative-url
Introduction:
Resolve a possibly relative URL agains a source URL. If the URL is not relative, return it unchanged.
(link, source)
Resolve a possibly relative URL
Arguments
link
- A possibly relative URL.source
- Source URL.
Example
var resolveRelative = require('resolve-relative-url');
var resolvedURL = resolveRelative('/banner.img', 'http://www.somedomain.com');
// http://www.somedomain.com/banner.img
var resolvedURL = resolveRelative('https://www.otherdomain.com/banner.img', 'http://www.somedomain.com');
// https://www.otherdomain.com/banner.img
var resolvedURL = resolveRelative('', 'http://www.somedomain.com');
// https://www.somedomain.com