/*
https://www.google.com/maps/dir/53.1518753,12.4661154/52.1956608,9.1839549/51.9431347,12.9028906/@51.1758057,10.4541194,6z/data=!4m2!4m1!3e0

*/
export const extractStops = (url) => {
  const route = url.split("@")[0]
  const match = route.match("^https?://(www\.)?google.[a-z]+/maps/dir/")
  if (match === null) {
    return []
  }
  const prefix = match[0]
  let stops = route.slice(match[0].length).split("/")
  if (stops[stops.length - 1] == "") {
    stops.pop()
  }
  
  return stops
}

export const buildUrl = (stops) => {
  return "https://www.google.com/maps/dir/" + stops.join("/") + "/"
}