<commit_before>require('dotenv').config();
const request = require('request-promise');

const googlemaps = {

  getResponse: (loc, placeStr, originalStr) => {
    // originalString is the text query!
    // var locRegex = /directions(.*)/gi;
    var locRegex = /directions(?:\s{1}to)*(.*)/gi;
    var location = locRegex.exec(originalStr);
    console.log('Location:', location);
    var destination = location[1];
    var rGeocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?` + 
      `latlng=${loc.lat},${loc.lon}&` +
      `result_type=street_address&` +
      `key=${process.env.googlemaps_api_key}`;

    console.log('rGeocodeUrl', rGeocodeUrl);
    return request(rGeocodeUrl)
      .then(res => {
        res = JSON.parse(res);
        var address = res.results[0].formatted_address;
        var data = `https://www.google.com/maps/embed/v1/directions?` + 
          `&destination=${destination}` +
          `&avoid=tolls|highways` +
          `&key=${process.env.googlemaps_api_key}` +
          `&origin=${address}`;
        
        let apiResponse = {
          type: 'widget',
          api: 'googlemap',
          text: 'You can do this.',
          data: data
        };

        return apiResponse;<commit_msg>Change google maps api text to include destination<commit_after>require('dotenv').config();
const request = require('request-promise');

const googlemaps = {

  getResponse: (loc, placeStr, originalStr) => {
    // originalString is the text query!
    // var locRegex = /directions(.*)/gi;
    var locRegex = /directions(?:\s{1}to)*(.*)/gi;
    var location = locRegex.exec(originalStr);
    console.log('Location:', location);
    var destination = location[1];
    var rGeocodeUrl = `https://maps.googleapis.com/maps/api/geocode/json?` + 
      `latlng=${loc.lat},${loc.lon}&` +
      `result_type=street_address&` +
      `key=${process.env.googlemaps_api_key}`;

    console.log('rGeocodeUrl', rGeocodeUrl);
    return request(rGeocodeUrl)
      .then(res => {
        res = JSON.parse(res);
        var address = res.results[0].formatted_address;
        var data = `https://www.google.com/maps/embed/v1/directions?` + 
          `&destination=${destination}` +
          `&avoid=tolls|highways` +
          `&key=${process.env.googlemaps_api_key}` +
          `&origin=${address}`;
        
        let apiResponse = {
          type: 'widget',
          api: 'googlemap',
          text: `Directions to ${destination}`,
          data: data
        };

        return apiResponse;
{'fraction_non_alphanumeric': 0.16383062920459043, 'fraction_numerical': 0.0031658092599920855, 'mean_word_length': 2.6744186046511627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6312349', 'n_tokens_mistral': 819, 'n_tokens_neox': 802, 'n_words': 139}