mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add support for Unicode usernames and group names
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
This commit is contained in:
@@ -44,7 +44,7 @@ function addHashtag(buffer, matches, state) {
|
||||
export function setup(helper) {
|
||||
helper.registerPlugin(md => {
|
||||
const rule = {
|
||||
matcher: /#([\u00C0-\u1FFF\u2C00-\uD7FF\w-:]{1,101})/,
|
||||
matcher: /#([\u00C0-\u1FFF\u2C00-\uD7FF\w:-]{1,101})/,
|
||||
onMatch: addHashtag
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -15,9 +15,14 @@ export class TextPostProcessRuler {
|
||||
|
||||
this.matcherIndex = [];
|
||||
|
||||
let rules = this.rules.map(
|
||||
r => "(" + r.rule.matcher.toString().slice(1, -1) + ")"
|
||||
);
|
||||
const rules = [];
|
||||
const flags = new Set("g");
|
||||
|
||||
this.rules.forEach(r => {
|
||||
const matcher = r.rule.matcher;
|
||||
rules.push(`(${matcher.source})`);
|
||||
matcher.flags.split("").forEach(f => flags.add(f));
|
||||
});
|
||||
|
||||
let i;
|
||||
let regexString = "";
|
||||
@@ -41,7 +46,7 @@ export class TextPostProcessRuler {
|
||||
last = "x".match(regex).length - 1;
|
||||
}
|
||||
|
||||
this.matcher = new RegExp(rules.join("|"), "g");
|
||||
this.matcher = new RegExp(rules.join("|"), [...flags].join(""));
|
||||
return this.matcher;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user