/interpolate-url

Interpolate urls containing /:colon variables

Primary LanguageJavaScriptMIT LicenseMIT

interpolate-url

Build Status

Basic api to do url interpolation using colons as the delimiter.

var interpolateUrl = require('interpolate-url');

var url = interpolateUrl('http://google.com/user/:id', {id: 10});

// url => http://google.com/user/10

var url = interpolateUrl('http://google.com/:type/:id', {type: 'car', id: 10});

// url => http://google.com/car/id

Also allows partial interpolation:

var url = interpolateUrl('http://google.com/:type/:id', {id: 10});

// url => http://google.com/:type/id