瀏覽代碼

Merge pull request #3564 from wanderingmeow/fix-regexp-safari-before-16.4

fix: RegExp "invalid group specifier name" exception on Safari < 16.4
Timothy Jaeryang Baek 10 月之前
父節點
當前提交
f3c1ff9efc
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/lib/utils/index.ts

+ 1 - 1
src/lib/utils/index.ts

@@ -525,7 +525,7 @@ export const extractSentences = (text) => {
 	});
 	});
 
 
 	// Split the modified text into sentences based on common punctuation marks, avoiding these blocks
 	// Split the modified text into sentences based on common punctuation marks, avoiding these blocks
-	let sentences = text.split(/(?<=[.!?])\s+/);
+	let sentences = text.match(/[^.?!]+[.!?]+[\])'"`’”]*|.+/g);
 
 
 	// Restore code blocks and process sentences
 	// Restore code blocks and process sentences
 	sentences = sentences.map((sentence) => {
 	sentences = sentences.map((sentence) => {