resolve-relative-url

Resolve a possibly relative URL agains a source URL

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
resolve-relative-url
201.0.08 years ago8 years agoMinified + gzip package size for resolve-relative-url in KB

Readme

resolve-relative-url
Build Status npm version Dependency Status devDependency Status

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