Skip to content

A platform for community discussion. Free, open, simple.

FIX: mention highlighting with case insensitive usernames (#38718)

David Battersbya5c7f6fab012
diff --git a/frontend/discourse/app/instance-initializers/current-user-mention-css.js b/frontend/discourse/app/instance-initializers/current-user-mention-css.js
index 8ced39a1cd2..5e5b08cfdb9 100644
--- a/frontend/discourse/app/instance-initializers/current-user-mention-css.js
+++ b/frontend/discourse/app/instance-initializers/current-user-mention-css.js
@@ -9,10 +9,10 @@ export default {
const currentUser = api.getCurrentUser();
if (currentUser) {
- const href = getURL(`/u/${currentUser.username.toLowerCase()}`);
+ const href = getURL(`/u/${currentUser.username}`);
const style = document.createElement("style");
style.id = "current-user-mention-css";
- style.textContent = `.mention[href="${href}"] { background: var(--tertiary-400); }`;
+ style.textContent = `.mention[href="${href}" i] { background: var(--tertiary-400); }`;
document.head.appendChild(style);
}
});
diff --git a/frontend/discourse/tests/acceptance/current-user-mention-css-test.js b/frontend/discourse/tests/acceptance/current-user-mention-css-test.js
index 3515ccfc9c3..c0b7d3a3482 100644
--- a/frontend/discourse/tests/acceptance/current-user-mention-css-test.js
+++ b/frontend/discourse/tests/acceptance/current-user-mention-css-test.js
@@ -5,13 +5,13 @@ import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("Current User Mention CSS", function (needs) {
needs.user({ username: "eviltrout" });
- test("css is generated for current user mentions", async function (assert) {
+ test("css uses case-insensitive matching for current user mentions", async function (assert) {
await visit("/");
const cssTag = document.querySelector("style#current-user-mention-css");
assert
.dom(cssTag)
.hasText(
- `.mention[href="/u/eviltrout"] { background: var(--tertiary-400); }`
+ `.mention[href="/u/eviltrout" i] { background: var(--tertiary-400); }`
);
});
});