hashToPath function
Normalizes a URL hash (#/foo) to a path (/foo); empty hash → /.
Implementation
String hashToPath(String hash) {
if (hash.isEmpty || hash == '#') return '/';
final raw = hash.startsWith('#') ? hash.substring(1) : hash;
return raw.startsWith('/') ? raw : '/$raw';
}