resolve-relative-url

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i resolve-relative-url

Weekly Downloads

5,315

Version

1.0.0

License

MIT

Last publish

Collaborators

  • eiriklv