0.1.0 • Published 11 years ago

extend-url v0.1.0

Weekly downloads
24
License
-
Repository
github
Last release
11 years ago

extend-url build status

testling badge

Splits a url into its parts and adds or replaces items found in the parts of another url.

var extendUrl = require('extend-url');

var url1 = 'https://joe:schmoe@api.github.com/users/thlorenz/repos?client_id=1&client_secret=2'
  , url2 = 'https://api.github.com/users/thlorenz/repos?page=1&per_page=10'
  , extended = extendUrl(url1, url2);

console.log(extended)
https://joe:schmoe@api.github.com/users/thlorenz/repos?client_id=1&client_secret=2&page=1&per_page=10

Installation

npm install extend-url

API

extendUrl(url1 : String, url2 : String) : String

Returns a url that extends url1 with url2 as follows:

  • protocol from url2
  • auth from url2 or url1 whichever is found first
  • pathname from url2
  • host from url2
  • search (query) url1's query extended with url2's query
0.1.0

11 years ago