Просмотр исходного кода

refs #84539: split double quote keywords block
- Replace RegExp separation

NEEDLEMAN3\tatsu 4 лет назад
Родитель
Сommit
8212da0ee9
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      packages/app/src/components/Page/RevisionRenderer.jsx

+ 7 - 2
packages/app/src/components/Page/RevisionRenderer.jsx

@@ -64,9 +64,14 @@ class LegacyRevisionRenderer extends React.PureComponent {
    */
   getHighlightedBody(body, keywords) {
     const normalizedKeywordsArray = [];
-    // !!TODO!!: care double quote
     // !!TODO!!: add test code
-    keywords.replace(/"/g, '').split(/[\u{20}\u{3000}]/u).forEach((keyword, i) => { // split by both full-with and half-width space
+    // Separate keywords
+    // - Surrounded by double quotation
+    // - Split by both full-width and half-width spaces
+    const splitKwds = [...keywords.match(/"[^"]+"|[^\u{20}\u{3000}]+/ug)];
+    splitKwds.forEach((kwd, i) => {
+      // Removes double quotes from keywords and trims start and end blanks
+      const keyword = kwd.replace(/"/g, '').trim();
       if (keyword === '') {
         return;
       }