mirror of
https://github.com/discourse/discourse.git
synced 2025-05-25 00:32:52 +08:00
FIX: allow underscore and dash in username search
_ and - are technically punctuations, but we allow them in usernames so accept them in search
This commit is contained in:
@ -112,13 +112,13 @@ function organizeResults(r, options) {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
// all punctuations except for . which is allowed in usernames
|
// all punctuations except for -, _ and . which are allowed in usernames
|
||||||
// note: these are valid in names, but will end up tripping search anyway so just skip
|
// note: these are valid in names, but will end up tripping search anyway so just skip
|
||||||
// this means searching for `sam saffron` is OK but if my name is `sam$ saffron` autocomplete
|
// this means searching for `sam saffron` is OK but if my name is `sam$ saffron` autocomplete
|
||||||
// will not find me, which is a reasonable compromise
|
// will not find me, which is a reasonable compromise
|
||||||
//
|
//
|
||||||
// we also ignore if we notice a double space or a string that is only a space
|
// we also ignore if we notice a double space or a string that is only a space
|
||||||
const ignoreRegex = /([\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-\/:;<=>?\[\]^_`{|}~])|\s\s|^\s$/;
|
const ignoreRegex = /([\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\/:;<=>?\[\]^`{|}~])|\s\s|^\s$/;
|
||||||
|
|
||||||
function skipSearch(term, allowEmails) {
|
function skipSearch(term, allowEmails) {
|
||||||
if (term.indexOf("@") > -1 && !allowEmails) {
|
if (term.indexOf("@") > -1 && !allowEmails) {
|
||||||
|
@ -89,6 +89,8 @@ QUnit.test("it skips a search depending on punctuations", async assert => {
|
|||||||
let allowedTerms = [
|
let allowedTerms = [
|
||||||
"@sam sam", // double space is not allowed
|
"@sam sam", // double space is not allowed
|
||||||
"@sam.sam",
|
"@sam.sam",
|
||||||
|
"@sam_sam",
|
||||||
|
"@sam-sam",
|
||||||
"@"
|
"@"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user