[markdown] Use StringBuffer in normalizeLinkLabel
diff --git a/pkgs/markdown/lib/src/util.dart b/pkgs/markdown/lib/src/util.dart index 81f0039..e604507 100644 --- a/pkgs/markdown/lib/src/util.dart +++ b/pkgs/markdown/lib/src/util.dart
@@ -38,14 +38,12 @@ /// /// [CommonMark spec] https://spec.commonmark.org/0.30/#link-label String normalizeLinkLabel(String label) { - var text = label.trim().replaceAll(_oneOrMoreWhitespacePattern, ' '); + final text = label.trim().replaceAll(_oneOrMoreWhitespacePattern, ' '); + final buffer = StringBuffer(); for (var i = 0; i < text.length; i++) { - final mapped = caseFoldingMap[text[i]]; - if (mapped != null) { - text = text.replaceRange(i, i + 1, mapped); - } + buffer.write(caseFoldingMap[text[i]] ?? text[i]); } - return text; + return buffer.toString(); } /// Normalizes a link destination, including the process of HTML characters