@@ -34,26 +34,30 @@ export const isSongMatch = (
3434) : boolean => {
3535 const normalizedResult = normalizeName ( resultName ) ;
3636 const normalizedOriginal = normalizeName ( match . songName ) ;
37- // 空字符串保护:避免 includes("") 恒为 true
38- if ( ! normalizedResult || ! normalizedOriginal ) return false ;
39- // 歌名:双向 includes(兼容一方带后缀的情况)
40- if (
41- ! normalizedResult . includes ( normalizedOriginal ) &&
42- ! normalizedOriginal . includes ( normalizedResult )
43- ) {
44- return false ;
37+ // songName 为空时跳过歌名检查(保持旧行为:不传 songName 则不限制歌名匹配)
38+ // normalizedResult 为空则视为无效结果,直接拒绝
39+ if ( ! normalizedResult ) return false ;
40+ if ( normalizedOriginal ) {
41+ // 歌名:双向 includes(兼容一方带后缀的情况)
42+ if (
43+ ! normalizedResult . includes ( normalizedOriginal ) &&
44+ ! normalizedOriginal . includes ( normalizedResult )
45+ ) {
46+ return false ;
47+ }
4548 }
4649 // 艺术家:归一化分隔符后双向 includes
4750 if ( resultArtist && match . artist ) {
4851 const normalizedResultArtist = normalizeArtist ( resultArtist ) ;
4952 const normalizedOriginalArtist = normalizeArtist ( match . artist ) ;
50- // 空字符串保护
51- if ( ! normalizedResultArtist || ! normalizedOriginalArtist ) return false ;
52- if (
53- ! normalizedResultArtist . includes ( normalizedOriginalArtist ) &&
54- ! normalizedOriginalArtist . includes ( normalizedResultArtist )
55- ) {
56- return false ;
53+ // 任一归一化后为空则跳过艺术家检查
54+ if ( normalizedResultArtist && normalizedOriginalArtist ) {
55+ if (
56+ ! normalizedResultArtist . includes ( normalizedOriginalArtist ) &&
57+ ! normalizedOriginalArtist . includes ( normalizedResultArtist )
58+ ) {
59+ return false ;
60+ }
5761 }
5862 }
5963 return true ;
0 commit comments