SULLEY\ryo-h 4 lat temu
rodzic
commit
54ba232008

+ 2 - 2
packages/app/src/components/SearchPage/SearchResultListItem.tsx

@@ -28,10 +28,10 @@ const SearchResultListItem: FC<Props> = (props:Props) => {
   // Add prefix 'id_' in pageId, because scrollspy of bootstrap doesn't work when the first letter of id attr of target component is numeral.
   const pageId = `#${page._id}`;
 
-  const isPathHighlighted = props.page.elasticSearchResult.highlightedPath != null;
+  const isPathIncludedHtml = props.page.elasticSearchResult.highlightedPath != null;
 
   const dPagePath = new DevidedPagePath(page.path, false, true);
-  const pagePathElem = <PagePathLabel path={props.page.elasticSearchResult.highlightedPath} isFormerOnly isPathHighlighted={isPathHighlighted} />;
+  const pagePathElem = <PagePathLabel path={props.page.elasticSearchResult.highlightedPath} isFormerOnly isPathIncludedHtml={isPathIncludedHtml} />;
 
   // TODO : send cetain  length of body (revisionBody) from elastisearch by adding some settings to the query and
   //         when keyword is not in page content, display revisionBody.

+ 0 - 13
packages/core/src/models/devided-page-path.js

@@ -4,8 +4,6 @@ import * as pathUtils from '../utils/path-utils';
 const PATTERN_INCLUDE_DATE = /^(.+\/[^/]+)\/(\d{4}|\d{4}\/\d{2}|\d{4}\/\d{2}\/\d{2})$/;
 // https://regex101.com/r/HJNvMW/1
 const PATTERN_DEFAULT = /^((.*)(?<!<)\/)?(.+)$/;
-// https://regex101.com/r/4J4JuR/1
-const PATTERN_PATH_WITH_ANY_HTML_TAGS = /<("[^"]*"|'[^']*'|[^'">])*>/g;
 
 export class DevidedPagePath {
 
@@ -36,17 +34,6 @@ export class DevidedPagePath {
       }
     }
 
-    // highlighted path
-    const regex = new RegExp(PATTERN_PATH_WITH_ANY_HTML_TAGS);
-    // testing whether the html tags exists in the path or not
-    if (regex.test(pagePath)) {
-      const matchDefault = pagePath.match(PATTERN_DEFAULT);
-      this.isFormerRoot = matchDefault[1] === '/';
-      this.former = matchDefault[2];
-      this.latter = matchDefault[3];
-      return;
-    }
-
     const matchDefault = pagePath.match(PATTERN_DEFAULT);
     if (matchDefault != null) {
       this.isFormerRoot = matchDefault[1] === '/';

+ 2 - 2
packages/ui/src/components/PagePath/PagePathLabel.jsx

@@ -10,7 +10,7 @@ export const PagePathLabel = (props) => {
   classNames = classNames.concat(props.additionalClassNames);
 
   const displayPath = (reactElement) => {
-    if (props.isPathHighlighted) {
+    if (props.isPathIncludedHtml) {
       // eslint-disable-next-line react/no-danger
       return <span dangerouslySetInnerHTML={{ __html: reactElement.props.children }}></span>;
     }
@@ -39,7 +39,7 @@ export const PagePathLabel = (props) => {
 PagePathLabel.propTypes = {
   isLatterOnly: PropTypes.bool,
   isFormerOnly: PropTypes.bool,
-  isPathHighlighted: PropTypes.bool,
+  isPathIncludedHtml: PropTypes.bool,
   additionalClassNames: PropTypes.arrayOf(PropTypes.string),
   path: PropTypes.string.isRequired,
 };