Skip to content

Instantly share code, notes, and snippets.

@ar45
Created February 24, 2016 15:01
Show Gist options
  • Save ar45/c65d7a6f6b4d0543e2fb to your computer and use it in GitHub Desktop.
Save ar45/c65d7a6f6b4d0543e2fb to your computer and use it in GitHub Desktop.
function interpolateUrl(url, params, replaceMissing) {
return url.replace(/:([^\/]+)/g, (match, p1) => {
return params[p1] || ( replaceMissing ? '' : match );
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment