-
Notifications
You must be signed in to change notification settings - Fork 0
fix: address PR #757 review comments #759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,5 +72,6 @@ export const CONTENT_PREVIEW_MAX_LENGTH = 120; | |
| export function buildContentPreview(text: string): string { | ||
| const trimmed = text.trim().replace(/\s+/g, " "); | ||
| if (trimmed.length <= CONTENT_PREVIEW_MAX_LENGTH) return trimmed; | ||
| return trimmed.slice(0, CONTENT_PREVIEW_MAX_LENGTH).trim() + "..."; | ||
| const headLength = Math.max(0, CONTENT_PREVIEW_MAX_LENGTH - 3); | ||
| return `${trimmed.slice(0, headLength).trim()}...`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -358,10 +358,12 @@ describe("aiServiceServer / callAIWithServer", () => { | |
| pulledOnce = true; | ||
| controller.enqueue(encoder.encode('data: {"content":"a"}\n')); | ||
| // 次の pull の前に abort | ||
| // Abort before the next pull. | ||
| abortController.abort(); | ||
| return; | ||
|
Comment on lines
+361
to
363
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この // Abort before the next pull.
abortController.abort();
controller.close();
return; |
||
| } | ||
| controller.enqueue(encoder.encode(":\n")); | ||
| controller.close(); | ||
| }, | ||
| }); | ||
| fetchSpy.mockResolvedValue(new Response(stream, { status: 200 })); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trimmed.slice(0, headLength)は UTF-16 コードユニット単位で文字列を切り出すため、サロゲートペア(絵文字や一部の漢字など)の途中で切断され、不正な文字列(文字化け)が発生する可能性があります。プレビュー用途では致命的ではありませんが、より堅牢にするにはIntl.Segmenterを使用するか、切り出し位置がサロゲートペアの間でないかを確認する処理を追加することを検討してください。なお、この修正を行う場合はserver/hocuspocus側の同名ファイルも同様に更新する必要があります。