Shun Miyazawa 3 лет назад
Родитель
Сommit
6fc59f3532

+ 0 - 2
packages/app/src/interfaces/search.ts

@@ -44,5 +44,3 @@ export const SORT_ORDER = {
   ASC: 'asc',
 } as const;
 export type SORT_ORDER = typeof SORT_ORDER[keyof typeof SORT_ORDER];
-
-export const MAX_HIGHLITE_PAGE_PATH_FRAGMENT_SIZE = 250;

+ 2 - 7
packages/app/src/server/service/search.ts

@@ -3,9 +3,7 @@ import xss from 'xss';
 
 import { SearchDelegatorName } from '~/interfaces/named-query';
 import { IPageHasId } from '~/interfaces/page';
-import {
-  IFormattedSearchResult, IPageWithSearchMeta, ISearchResult, MAX_HIGHLITE_PAGE_PATH_FRAGMENT_SIZE,
-} from '~/interfaces/search';
+import { IFormattedSearchResult, IPageWithSearchMeta, ISearchResult } from '~/interfaces/search';
 import loggerFactory from '~/utils/logger';
 
 import { ObjectIdLike } from '../interfaces/mongoose-utils';
@@ -457,12 +455,9 @@ class SearchService implements SearchQueryParser, SearchResolver {
         const pathMatch = highlightData['path.en'] || highlightData['path.ja'];
         const isHtmlInPath = highlightData['path.en'] != null || highlightData['path.ja'] != null;
 
-        const highlightedPath = pathMatch != null && typeof pathMatch[0] === 'string' ? pathMatch[0] : null;
-        const shouldHighlight = highlightedPath != null && MAX_HIGHLITE_PAGE_PATH_FRAGMENT_SIZE >= pageData.path.length;
-
         elasticSearchResult = {
           snippet: snippet != null && typeof snippet[0] === 'string' ? filterXss.process(snippet) : null,
-          highlightedPath: shouldHighlight ? filterXss.process(highlightedPath) : null,
+          highlightedPath: pathMatch != null && typeof pathMatch[0] === 'string' ? filterXss.process(pathMatch) : null,
           isHtmlInPath,
         };
       }