MCPcopy
hub / github.com/sjdonado/idonthavespotify / cleanSearchQuery

Function cleanSearchQuery

src/utils/query.ts:5–32  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

3 * while preserving valid content (including emojis, $, !, etc.)
4 */
5export function cleanSearchQuery(query: string): string {
6 return (
7 query
8 // Remove special quotation marks (German „", French «», Asian 『』, etc.)
9 // U+201E „ U+201C " U+201D " U+00AB « U+00BB » U+2039 ‹ U+203A › U+300E 『 U+300F 』 U+300C 「 U+300D 」
10 .replace(
11 /[\u201E\u201C\u201D\u00AB\u00BB\u2039\u203A\u300E\u300F\u300C\u300D]/g,
12 ''
13 )
14 // Normalize fancy apostrophes to standard apostrophe
15 // U+2018 ' U+2019 ' U+201A ‚ U+201B ‛
16 .replace(/[\u2018\u2019\u201A\u201B]/g, "'")
17 // Normalize fancy double quotes to nothing (remove them)
18 // U+201C " U+201D "
19 .replace(/[\u201C\u201D]/g, '')
20 // Remove middle dot (often used as metadata separator, not part of titles)
21 // U+00B7 ·
22 .replace(/\u00B7/g, ' ')
23 // Normalize various dash types to standard hyphen
24 // U+2013 – U+2014 — U+2015 ―
25 .replace(/[\u2013\u2014\u2015]/g, '-')
26 // Remove zero-width characters
27 .replace(/[\u200B-\u200D\uFEFF]/g, '')
28 // Collapse multiple spaces and trim
29 .replace(/\s+/g, ' ')
30 .trim()
31 );
32}

Callers 3

scoreMatchFunction · 0.90
searchFunction · 0.90
query.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected