function getNumberOfUrlSegments(url) {
  // split at '/' or at '\/' to split regex urls correctly
  return url.split(/\\?\//).filter(s => s.length > 0 && s !== ',').length;
}
Takes a URL object and returns a sanitized string which is safe to use as span description
see: https://develop.sentry.dev/sdk/data-handling/#structuring-data