Skip to content

Commit

Permalink
[MIM-2082] Mim 2082 add backticks quotemarks (#3047)
Browse files Browse the repository at this point in the history
* Add backticks, quotation marks to allowed symbols

* Improve search by replacing forward-ticks with apostrophes

* Add backticks too, also replace with quotemark

* Replaces single character alternation with set, after quality control
  • Loading branch information
Glenruben authored Nov 25, 2024
1 parent b65d377 commit a9c995d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/resources/lib/ssb/utils/nameSearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ export function sanitizeQuery(name: string): string {
}
// Allowed characters, extracted from name data using this little script, ensuring we include all actually used characters:
// https://gist.github.com/Glenruben/2e2b2a32ddbfe4216d8b0791e3667635
const approved = '-ABCDEFGHIJKLMNOPQRSTUVWXYZÁÄÅÆÈÉËÍÏÑÓÔÖØÜÝ '
return whitelist(name.toUpperCase(), approved)
// We also replace forwards tick with apostrophe, because it is used in names but does not appear in our data.
const approved = `-'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÄÅÆÈÉËÍÏÑÓÔÖØÜÝ `
return whitelist(name.replace(/[´`]/g, "'").toUpperCase(), approved)
}

//Uses when repo dont exist
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/site/parts/nameSearch/nameSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function NameSearch(props) {
function isNameValid(nameToCheck) {
// Regexp: Note use of 'i' flag, making the match case insensitive. Also, remember regexp ranges are based on unicode character codes.
const invalidCharacters =
!!nameToCheck && nameToCheck.match(/[^a-zABCDEFGHIJKLMNOPQRSTUVWXYZÁÄÅÆÈÉËÍÏÑÓÔÖØÜÝ\-\s]/gim)
!!nameToCheck && nameToCheck.match(/[^a-zABCDEFGHIJKLMNOPQRSTUVWXYZÁÄÅÆÈÉËÍÏÑÓÔÖØÜÝ\-'´`\s]/gim)
return !invalidCharacters
}

Expand Down

0 comments on commit a9c995d

Please sign in to comment.