diff --git a/e2e/integration/search.e2e.ts b/e2e/integration/search.e2e.ts index 5785ee807a..35b30dbb70 100644 --- a/e2e/integration/search.e2e.ts +++ b/e2e/integration/search.e2e.ts @@ -59,4 +59,20 @@ describe('Search', () => { getSearchInput().type('xzss', { force: true }); getSearchResults().should('exist').should('contain', 'No results found'); }); + + it('should allow search by path or keywords in path', () => { + getSearchInput().clear().type('uploadImage', { force: true }); + cy.get('[role=search] [role=menuitem]') + .should('have.length', 1) + .first() + .should('contain', 'uploads an image'); + + getSearchInput() + .clear() + .type('/pet/{petId}/uploadImage', { force: true, parseSpecialCharSequences: false }); + cy.get('[role=search] [role=menuitem]') + .should('have.length', 1) + .first() + .should('contain', 'uploads an image'); + }); }); diff --git a/src/services/SearchStore.ts b/src/services/SearchStore.ts index 4600c0ec6c..feb19c6970 100644 --- a/src/services/SearchStore.ts +++ b/src/services/SearchStore.ts @@ -26,7 +26,7 @@ export class SearchStore { const recurse = items => { items.forEach(group => { if (group.type !== 'group') { - this.add(group.name, group.description || '', group.id); + this.add(group.name, (group.description || '').concat(' ', group.path || ''), group.id); } recurse(group.items); }); diff --git a/src/services/SearchWorker.worker.ts b/src/services/SearchWorker.worker.ts index 764370f190..5b53565647 100644 --- a/src/services/SearchWorker.worker.ts +++ b/src/services/SearchWorker.worker.ts @@ -37,7 +37,10 @@ function initEmpty() { initEmpty(); -const expandTerm = term => '*' + lunr.stemmer(new lunr.Token(term, {})) + '*'; +const expandTerm = term => { + const token = lunr.trimmer(new lunr.Token(term, {})); + return '*' + lunr.stemmer(token) + '*'; +}; export function add(title: string, description: string, meta?: T) { const ref = store.push(meta) - 1;