From 575f8ec0d10b5a9db12e22e60a71d99b7b24da88 Mon Sep 17 00:00:00 2001
From: Koy Zhuang <369491420@qq.com>
Date: Wed, 26 Oct 2022 22:36:01 +0800
Subject: [PATCH] Revert "fix: fix search with no content. (#1878)"
This reverts commit 930ad956effe417a9983e1dba36d2b8b11993bc7.
---
src/plugins/search/search.js | 15 +++++++--------
test/e2e/search.test.js | 20 --------------------
2 files changed, 7 insertions(+), 28 deletions(-)
diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js
index 3266b7bb4f..91a21094e6 100644
--- a/src/plugins/search/search.js
+++ b/src/plugins/search/search.js
@@ -211,15 +211,14 @@ export function search(query) {
}
const matchContent =
- handlePostContent &&
'...' +
- handlePostContent
- .substring(start, end)
- .replace(
- regEx,
- word => `${word}`
- ) +
- '...';
+ handlePostContent
+ .substring(start, end)
+ .replace(
+ regEx,
+ word => `${word}`
+ ) +
+ '...';
resultStr += matchContent;
}
diff --git a/test/e2e/search.test.js b/test/e2e/search.test.js
index ed79f05f9e..cab645184f 100644
--- a/test/e2e/search.test.js
+++ b/test/e2e/search.test.js
@@ -176,24 +176,4 @@ test.describe('Search Plugin Tests', () => {
await searchFieldElm.fill('hello');
await expect(resultsHeadingElm).toHaveText('Changelog Title');
});
- test('search when there is no body', async ({ page }) => {
- const docsifyInitConfig = {
- markdown: {
- homepage: `
- # EmptyContent
- ---
- ---
- `,
- },
- scriptURLs: ['/lib/plugins/search.min.js'],
- };
-
- const searchFieldElm = page.locator('input[type=search]');
- const resultsHeadingElm = page.locator('.results-panel h2');
-
- await docsifyInit(docsifyInitConfig);
-
- await searchFieldElm.fill('empty');
- await expect(resultsHeadingElm).toHaveText('EmptyContent');
- });
});