dspace-angular
dspace-angular copied to clipboard
Search in sidebar/facet don't escape special characters
References
- Fixes #1900
- PR #8529
Description
The facet search, that uses the endpoint /server/api/discover/facets/{facetName}
, in the search sidebar (expand filter in sidebar, start typing in search bar of that facet) didn't escape special characters.
Instructions for Reviewers
- Go to search
- Expand the sidebar filter and start typing search bar
- (see network tab) The search query gets sent to
/server/api/discover/facets/{facetName}?prefix={query}
lowercased and url escaped -
For example if you search by subject and you enter as value
&fakeparam=test
on demo7 this call will be made/server/api/discover/facets/subject?prefix=&fakeparam=test&page=0&size=5&configuration=default
but now with this fix this request will be made instead:/server/api/discover/facets/subject?prefix=%26fakeparam%3Dtest&page=0&size=5&configuration=default
Checklist
- [x] My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
- [x] My PR passes TSLint validation using
yarn run lint
- [x] My PR doesn't introduce circular dependencies
- [x] My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
- [x] My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
- [x] If my PR includes new, third-party dependencies (in
package.json
), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
hello @alexandrevryghem
What we do is to normalize the string, we remove the accents, more or less like this
indexOfCoincidence(completeTerm: string, subTerm: string){ completeTerm = completeTerm.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toUpperCase(); subTerm = subTerm.normalize('NFD').replace(/[\u0300-\u036f]/g, "").toUpperCase(); return completeTerm.indexOf(subTerm) }
If you like my idea, I can check it in more detail, it works like this:
Hey @jtimal
I looked into this and your solution does indeed work for normalizing the accents but it would also require extra backend changes to ignore accents when searching for the results too. So you should probably create a new issue for this.
Hi @alexandrevryghem thanks for reading me,
Ok, I'm fine with it, I just don't know how to create this request, do we wait for Tim to review it or do we let him know?
I just don't know how to create this request
In the issues tab you just need to click on the Create Issue button and describe the bug/feature.
do we wait for Tim to review it or do we let him know?
He will read the new issue you create 🤷♂️ and if you want his feedback you should @ him
Very thanks @alexandrevryghem ,
I'd better wait until @tdonohue can read this part and tell me how I can help.