extractOriginalRoute = (
  path,
  regexp,
  keys,
) => {
  if (
    !path ||
    !regexp ||
    !keys ||
    Object.keys(keys).length === 0 ||
    _optionalChain([keys, 'access', _10 => _10[0], 'optionalAccess', _11 => _11.offset]) === undefined ||
    _optionalChain([keys, 'access', _12 => _12[0], 'optionalAccess', _13 => _13.offset]) === null
  ) {
    return undefined;
  }
  const orderedKeys = keys.sort((a, b) => a.offset - b.offset);

  // add d flag for getting indices from regexp result
  // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor -- regexp comes from express.js
  const pathRegex = new RegExp(regexp, `${regexp.flags}d`);
  /**
   * use custom type cause of TS error with missing indices in RegExpExecArray
   */
  const execResult = pathRegex.exec(path) ;

  if (!execResult || !execResult.indices) {
    return undefined;
  }
  /**
   * remove first match from regex cause contain whole layer.path
   */
  const [, ...paramIndices] = execResult.indices;

  if (paramIndices.length !== orderedKeys.length) {
    return undefined;
  }
  let resultPath = path;
  let indexShift = 0;

  /**
   * iterate param matches from regexp.exec
   */
  paramIndices.forEach((item, index) => {
    /** check if offsets is define because in some cases regex d flag returns undefined */
    if (item) {
      const [startOffset, endOffset] = item;
      /**
       * isolate part before param
       */
      const substr1 = resultPath.substring(0, startOffset - indexShift);
      /**
       * define paramName as replacement in format :pathParam
       */
      const replacement = `:${orderedKeys[index].name}`;

      /**
       * isolate part after param
       */
      const substr2 = resultPath.substring(endOffset - indexShift);

      /**
       * recreate original path but with param replacement
       */
      resultPath = substr1 + replacement + substr2;

      /**
       * calculate new index shift after resultPath was modified
       */
      indexShift = indexShift + (endOffset - startOffset - replacement.length);
    }
  });

  return resultPath;
}
Recreate layer.route.path from layer.regexp and layer.keys.
Works until express.js used package path-to-regexp@0.1.7
or until layer.keys contain offset attribute

@param layer the layer to extract the stringified route from

@returns string in layer.route.path structure 'router/:pathParam' or undefined