currentPath property

  1. @override
String get currentPath

Current page path without the baseUrl.

Implementation

@override
String get currentPath {
  if (_currentPath != null) return _currentPath;

  final path = location.pathname + location.search + location.hash;
  final basePath = _basePath;
  if (basePath.isEmpty || !path.startsWith(basePath)) return path;

  final relative = path.substring(basePath.length);
  if (relative.isNotEmpty && !'/?#'.contains(relative[0])) return path;

  return relative.startsWith('/') ? relative : '/$relative';
}