Skip to content

Commit 07e7a26

Browse files
committed
Fix up utils
1 parent b16f863 commit 07e7a26

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

lib/src/utils.dart

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,13 @@ String stripComments(String str) {
4141
return buf.toString().trim();
4242
}
4343

44-
/// This is special because it knows not to leave HTML tags open.
45-
/// Do not call this on unsanitized HTML.
4644
String truncateString(String str, int length) {
47-
assert(str == null || !str.contains("<"));
48-
if (str != null) {
49-
if (str.length > length) {
50-
return '${str.substring(0, length)}…';
51-
}
52-
return str;
45+
if (str != null && str.length > length) {
46+
// Do not call this on unsanitized HTML.
47+
assert(!str.contains("<"));
48+
return '${str.substring(0, length)}…';
5349
}
54-
return null;
50+
return str;
5551
}
5652

5753
String pluralize(String word, int count) => count == 1 ? word : '${word}s';

pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,4 +350,4 @@ packages:
350350
source: hosted
351351
version: "2.1.13"
352352
sdks:
353-
dart: ">=1.23.0 <=2.0.0-dev.7.0"
353+
dart: ">=1.23.0 <=2.0.0-dev.8.0"

0 commit comments

Comments
 (0)