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'); - }); });