route-regex.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. export interface Group {
  2. pos: number;
  3. repeat: boolean;
  4. optional: boolean;
  5. }
  6. export interface RouteRegex {
  7. groups: {
  8. [groupName: string]: Group;
  9. };
  10. re: RegExp;
  11. }
  12. /**
  13. * From a normalized route this function generates a regular expression and
  14. * a corresponding groups object inteded to be used to store matching groups
  15. * from the regular expression.
  16. */
  17. export declare function getRouteRegex(normalizedRoute: string): RouteRegex;
  18. /**
  19. * This function extends `getRouteRegex` generating also a named regexp where
  20. * each group is named along with a routeKeys object that indexes the assigned
  21. * named group with its corresponding key.
  22. */
  23. export declare function getNamedRouteRegex(normalizedRoute: string): {
  24. namedRegex: string;
  25. routeKeys: {
  26. [named: string]: string;
  27. };
  28. groups: {
  29. [groupName: string]: Group;
  30. };
  31. re: RegExp;
  32. };
  33. /**
  34. * Generates a named regexp.
  35. * This is intended to be using for build time only.
  36. */
  37. export declare function getNamedMiddlewareRegex(normalizedRoute: string, options: {
  38. catchAll?: boolean;
  39. }): {
  40. namedRegex: string;
  41. };