normalizePath method

String normalizePath (String path)

Normalizes path for navigation.

This determines the representation of path used to manipulate browser history and exposed through router states.

Implementation

String normalizePath(String path) {
  if (path == null) return null;

  if (!path.startsWith('/')) {
    path = '/$path';
  }

  if (path.endsWith('/')) {
    path = path.substring(0, path.length - 1);
  }

  return path;
}