(value)
| 122 | } |
| 123 | |
| 124 | function normalizeSource(value) { |
| 125 | const s = String(value || "").trim(); |
| 126 | if (!s) return s; |
| 127 | // Normalize YouTube URLs to the bare video ID so that youtu.be/xxx, |
| 128 | // youtube.com/watch?v=xxx, and variants with &t= / ?si= all match. |
| 129 | const yt = s.match(/(?:youtu\.be\/|[?&]v=)([a-zA-Z0-9_-]{11})/); |
| 130 | if (yt) return `yt:${yt[1]}`; |
| 131 | return s; |
| 132 | } |
| 133 | |
| 134 | function normalizeSearch(value) { |
| 135 | return String(value || "").trim().toLowerCase(); |