improved Uri display formatting

This commit is contained in:
Fabian Freund
2026-04-28 17:55:48 +02:00
parent 4a54b8ee83
commit 845c9a1cfc
3 changed files with 46 additions and 18 deletions
+9 -12
View File
@@ -47,18 +47,11 @@ extension UriX on Uri {
return '';
}
final segments = pathSegments.join('/');
final buffer = StringBuffer();
if (path.startsWith('/')) {
buffer.write('/');
try {
return Uri.decodeComponent(path);
} on FormatException {
return path;
}
buffer.write(segments);
if (path.length > 1 && path.endsWith('/')) {
buffer.write('/');
}
return buffer.toString();
}
String get displayString {
@@ -94,6 +87,10 @@ extension UriStringX on String {
if (uri == null || uri.toString() != this) {
return this;
}
return uri.displayString;
try {
return uri.displayString;
} on FormatException {
return this;
}
}
}