Skip to content

Commit

Permalink
Use encodeURIComponent instead of querystring.escape
Browse files Browse the repository at this point in the history
This makes it compatible with bundlers that don't provide
querystring.escape. See here for details:

mhart/aws4#46
  • Loading branch information
josephfrazier committed Oct 7, 2017
1 parent f644888 commit a59715e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const googleMaps = require('@google/maps')
const makeUrlRequest = require('@google/maps/lib/internal/make-url-request.js')
const querystring = require('querystring')
const sortOn = require('sort-on')

const enumerateWaypointSets = require('./rook.js')
Expand Down Expand Up @@ -92,7 +91,7 @@ function reorderWaypoints ({route, waypoints}) {

function getMapsLink ({origin, destination, waypoints}) {
const allWaypoints = [origin].concat(waypoints).concat(destination)
const escapedWaypoints = allWaypoints.map(querystring.escape).join('/')
const escapedWaypoints = allWaypoints.map(encodeURIComponent).join('/')
const dataString = '!4m2!4m1!3e1' // https://webapps.stackexchange.com/questions/67190/how-can-i-encode-my-preference-of-biking-walking-public-transport-in-a-google-ma/78800#78800
return `https://www.google.com/maps/dir/${escapedWaypoints}/data=${dataString}`
}

0 comments on commit a59715e

Please sign in to comment.