diff options
author | Mathieu Suen <mathieu.suen@sonarsource.com> | 2021-09-15 09:40:35 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-09-16 20:03:30 +0000 |
commit | 08d22267853e09b119fd6b85f3a3c829c480f072 (patch) | |
tree | e01b6d22489fe606dd0d7b2077f53d892949eb03 /server/sonar-web/src/main/js/apps/documentation | |
parent | 34f1ac3955290cba9ba73fd07e98dc7a9fa9c0e5 (diff) | |
download | sonarqube-08d22267853e09b119fd6b85f3a3c829c480f072.tar.gz sonarqube-08d22267853e09b119fd6b85f3a3c829c480f072.zip |
SONAR-15391 Fix special caracter search in documentation
Diffstat (limited to 'server/sonar-web/src/main/js/apps/documentation')
3 files changed, 29 insertions, 28 deletions
diff --git a/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx b/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx index 4ec73f848d3..9640472b73c 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/SearchResults.tsx @@ -57,6 +57,7 @@ export default class SearchResults extends React.PureComponent<Props> { const results = this.index .search( query + .replace(/[\^\-+:~*]/g, '') .split(/\s+/) .map(s => `${s}~1 ${s}*`) .join(' ') diff --git a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx index 6c6764a97e2..88d5acffaa3 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx +++ b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/SearchResults-test.tsx @@ -90,7 +90,7 @@ it('should search', () => { <SearchResults navigation={['lorem/index', 'lorem/origin', 'foobar']} pages={pages} - query="simply text" + query="si:+mply text" splat="foobar" /> ); diff --git a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/__snapshots__/SearchResults-test.tsx.snap b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/__snapshots__/SearchResults-test.tsx.snap index ae5779ca00c..65b92fef234 100644 --- a/server/sonar-web/src/main/js/apps/documentation/components/__tests__/__snapshots__/SearchResults-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/documentation/components/__tests__/__snapshots__/SearchResults-test.tsx.snap @@ -3,76 +3,76 @@ exports[`should search 1`] = ` <Fragment> <SearchResultEntry - active={true} - key="foobar" + active={false} + key="lorem/origin" result={ Object { - "exactMatch": true, + "exactMatch": false, "highlights": Object { "text": Array [ Array [ - 111, + 15, 6, ], Array [ - 118, + 28, 4, ], ], "title": Array [ Array [ - 23, - 4, + 19, + 5, ], ], }, - "longestTerm": "simply", + "longestTerm": "", "page": Object { - "content": "Foobar is a universal variable understood to represent whatever is being discussed. Now we need some keywords: simply text.", + "content": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.", "navTitle": undefined, - "relativeName": "foobar", - "text": "Foobar is a universal variable understood to represent whatever is being discussed. Now we need some keywords: simply text.", - "title": "Where does Foobar come from?", - "url": "/foobar", + "relativeName": "lorem/origin", + "text": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.", + "title": "Where does it come from?", + "url": "/lorem/origin", }, - "query": "simply text", + "query": "si:+mply text", } } /> <SearchResultEntry - active={false} - key="lorem/origin" + active={true} + key="foobar" result={ Object { "exactMatch": false, "highlights": Object { "text": Array [ Array [ - 15, + 111, 6, ], Array [ - 28, + 118, 4, ], ], "title": Array [ Array [ - 19, - 5, + 23, + 4, ], ], }, - "longestTerm": "simply", + "longestTerm": "", "page": Object { - "content": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.", + "content": "Foobar is a universal variable understood to represent whatever is being discussed. Now we need some keywords: simply text.", "navTitle": undefined, - "relativeName": "lorem/origin", - "text": "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words.", - "title": "Where does it come from?", - "url": "/lorem/origin", + "relativeName": "foobar", + "text": "Foobar is a universal variable understood to represent whatever is being discussed. Now we need some keywords: simply text.", + "title": "Where does Foobar come from?", + "url": "/foobar", }, - "query": "simply text", + "query": "si:+mply text", } } /> |