function expand(url, params, variables) {
  var tmpl = parse(url),
      expanded = tmpl.expand(params);

  if (variables) {
    variables.push.apply(variables, tmpl.vars);
  }

  return expanded;
}
URL Template v2.0.6 (https://github.com/bramstein/url-template)