wingbot 3.27.0-alpha.5 → 3.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -58,6 +58,14 @@ const { replaceDiacritics } = require('../utils');
|
|
|
58
58
|
|
|
59
59
|
/** @typedef {import('../Request')} Request */
|
|
60
60
|
|
|
61
|
+
function optionalWrap (l, r, content) {
|
|
62
|
+
const consistent = !l === !r;
|
|
63
|
+
if (consistent) {
|
|
64
|
+
return `(${content})`;
|
|
65
|
+
}
|
|
66
|
+
return `${l || ''}(${content})${r || ''}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
61
69
|
class CustomEntityDetectionModel {
|
|
62
70
|
|
|
63
71
|
/**
|
|
@@ -508,16 +516,16 @@ class CustomEntityDetectionModel {
|
|
|
508
516
|
return null;
|
|
509
517
|
}
|
|
510
518
|
|
|
511
|
-
let replaced = source.replace(
|
|
519
|
+
let replaced = source.replace(/(\()?@([A-Z0-9-]+)(\))?/g, (value, l, ent, r) => {
|
|
512
520
|
const matchingEntities = entities
|
|
513
|
-
.filter((e) =>
|
|
521
|
+
.filter((e) => e.entity.toUpperCase() === ent)
|
|
514
522
|
.map((e) => this._escapeRegex(e.text, options.replaceDiacritics));
|
|
515
523
|
|
|
516
524
|
if (matchingEntities.length === 0) {
|
|
517
|
-
return
|
|
525
|
+
return optionalWrap(l, r, `@${ent}`);
|
|
518
526
|
}
|
|
519
527
|
matchingEntities.sort((a, z) => z.length - a.length);
|
|
520
|
-
return
|
|
528
|
+
return optionalWrap(l, r, matchingEntities.join('|'));
|
|
521
529
|
});
|
|
522
530
|
|
|
523
531
|
if (options.matchWholeWords && !searchWithinWords) {
|