diff --git a/backend/app/store/formatter.go b/backend/app/store/formatter.go index 0522eef9..e44cd114 100644 --- a/backend/app/store/formatter.go +++ b/backend/app/store/formatter.go @@ -83,7 +83,8 @@ func (f *CommentFormatter) shortenAutoLinks(commentHTML string, max int) (resHTM if host == "" { return } - short := href[:max-3] + + short := string([]rune(href)[:max-3]) if len(short) < len(host) { short = host } diff --git a/backend/app/store/formatter_test.go b/backend/app/store/formatter_test.go index 6517ecbb..90e7067c 100644 --- a/backend/app/store/formatter_test.go +++ b/backend/app/store/formatter_test.go @@ -25,6 +25,10 @@ func TestFormatter_FormatText(t *testing.T) { "

http://127.0.0." + "1/some-long-link/12345/6789012...

\n!converted", "links", }, + { + "something https://amp.dw.com/ru/илон-маск-купил-twitter/a-61590911", + "

something https://amp.dw.com/ru/илон-маск-купил-twitter...

\n!converted", "links", + }, { "something _aaa_", "

something aaa

\n!converted",