diff --git a/js/ui/components/VideoModal.js b/js/ui/components/VideoModal.js index e0dafdbe..8bf412dd 100644 --- a/js/ui/components/VideoModal.js +++ b/js/ui/components/VideoModal.js @@ -38,7 +38,6 @@ import { formatShortNpub as defaultFormatShortNpub, } from "../../utils/formatters.js"; import { sanitizeProfileMediaUrl } from "../../utils/profileMedia.js"; -import { normalizeHashtag } from "../../utils/hashtagNormalization.js"; import { getBreakpointLg } from "../../designSystem/metrics.js"; import { LinkPreviewService } from "../../services/linkPreviewService.js"; import { @@ -3224,19 +3223,29 @@ export class VideoModal { } const raw = typeof entry === "string" ? entry : String(entry ?? ""); - const trimmed = normalizeHashtag(raw); + const trimmed = raw.trim(); if (!trimmed) { continue; } - const key = trimmed.toLocaleLowerCase(); + let key = trimmed.toLowerCase(); + if (key.startsWith("#")) { + key = key.slice(1); + } + + if (!key) { + continue; + } + if (seen.has(key)) { continue; } seen.add(key); - normalized.push(trimmed); + + const display = trimmed.startsWith("#") ? trimmed : `#${trimmed}`; + normalized.push(display); } return normalized.sort((a, b) => diff --git a/js/ui/components/tagPillList.js b/js/ui/components/tagPillList.js index ea89704e..509774d9 100644 --- a/js/ui/components/tagPillList.js +++ b/js/ui/components/tagPillList.js @@ -63,11 +63,12 @@ function createTagButton({ doc, tag, onTagActivate, getTagState }) { button.type = "button"; button.classList.add("pill", "video-tag-pill", "focus-ring"); button.dataset.tag = tag; - button.title = `#${tag}`; + const displayTag = tag.startsWith("#") ? tag : `#${tag}`; + button.title = displayTag; const label = doc.createElement("span"); label.className = "video-tag-pill__label"; - label.textContent = `#${tag}`; + label.textContent = displayTag; const icon = doc.createElement("span"); icon.className = "video-tag-pill__icon"; diff --git a/tests/video-modal-accessibility.test.mjs b/tests/video-modal-accessibility.test.mjs index 98d809cc..560779f9 100644 --- a/tests/video-modal-accessibility.test.mjs +++ b/tests/video-modal-accessibility.test.mjs @@ -33,9 +33,8 @@ export async function setupModal({ lazyLoad = false } = {}) { // jsdom defines HTMLMediaElement but .pause/.load throw "Not implemented". // Replace with safe no-ops for tests that just depend on calls happening. if (window.HTMLMediaElement && window.HTMLMediaElement.prototype) { - const proto = window.HTMLMediaElement.prototype; - proto.pause = () => {}; - proto.load = () => {}; + window.HTMLMediaElement.prototype.pause = function () {}; + window.HTMLMediaElement.prototype.load = function () {}; } globalThis.HTMLElement = window.HTMLElement; @@ -47,15 +46,6 @@ export async function setupModal({ lazyLoad = false } = {}) { globalThis.Node = window.Node; globalThis.EventTarget = window.EventTarget; - if (typeof window.HTMLMediaElement !== "undefined") { - window.HTMLMediaElement.prototype.pause = function () {}; - window.HTMLMediaElement.prototype.load = function () {}; - } - if (typeof window.HTMLVideoElement !== "undefined") { - window.HTMLVideoElement.prototype.pause = function () {}; - window.HTMLVideoElement.prototype.load = function () {}; - } - try { Object.defineProperty(globalThis, "navigator", { value: window.navigator, @@ -458,13 +448,9 @@ async function setupPlaybackHarness() { globalThis.Node = window.Node; globalThis.EventTarget = window.EventTarget; - if (typeof window.HTMLMediaElement !== "undefined") { - if (!window.HTMLMediaElement.prototype.pause) { - window.HTMLMediaElement.prototype.pause = function () {}; - } - if (!window.HTMLMediaElement.prototype.load) { - window.HTMLMediaElement.prototype.load = function () {}; - } + if (window.HTMLMediaElement && window.HTMLMediaElement.prototype) { + window.HTMLMediaElement.prototype.pause = function () {}; + window.HTMLMediaElement.prototype.load = function () {}; } try {