@@ -27,25 +27,51 @@ export const shortHeaderUrl = (raw: unknown): string => {
2727 }
2828}
2929
30- export const normalizeDynamicFallbackTechName = ( name : unknown ) : string => {
31- const normalized = String ( name || '' )
30+ const normalizeFrontendTechKey = ( name : unknown ) : string =>
31+ String ( name || '' )
3232 . toLowerCase ( )
3333 . replace ( / ^ 疑 似 前 端 库 : \s * / , '' )
3434 . replace ( / (?: \. j s | j s ) $ / i, '' )
3535 . replace ( / (?: [ . _ - ] p k g d ) $ / i, '' )
3636 . replace ( / [ ^ a - z 0 - 9 一 - 龥 ] + / g, '' )
3737
38+ export const normalizeDynamicFallbackTechName = ( name : unknown ) : string => {
39+ const normalized = normalizeFrontendTechKey ( name )
3840 const aliases : Record < string , string > = {
3941 clipboardjs : 'clipboard' ,
42+ jquerycompat : 'jquery' ,
4043 imagesloadedjs : 'imagesloaded' ,
4144 slickcarousel : 'slick' ,
45+ twitterbootstrap : 'bootstrap' ,
4246 vuejs : 'vue'
4347 }
4448 return aliases [ normalized ] || normalized
4549}
4650
4751export const isFrontendFallback = ( item : any ) => item ?. category === '前端库' && / ^ 疑 似 前 端 库 : / i. test ( String ( item ?. name || '' ) . trim ( ) )
4852
53+ const frontendTechnologyCategories = new Set ( [ '前端库' , '前端框架' , 'UI / CSS 框架' ] )
54+
55+ const frontendAliasTechnologies : Record < string , { category : string ; name : string } > = {
56+ jquerycompat : { category : '前端库' , name : 'jQuery' } ,
57+ twitterbootstrap : { category : 'UI / CSS 框架' , name : 'Bootstrap' }
58+ }
59+
60+ export const canonicalizeFrontendAliasTechnologies = ( items : any [ ] ) => {
61+ if ( ! Array . isArray ( items ) || ! items . length ) return [ ]
62+
63+ return items . map ( item => {
64+ if ( ! frontendTechnologyCategories . has ( item ?. category ) ) return item
65+ const canonical = frontendAliasTechnologies [ normalizeFrontendTechKey ( item . name ) ]
66+ if ( ! canonical ) return item
67+ return {
68+ ...item ,
69+ category : canonical . category ,
70+ name : canonical . name
71+ }
72+ } )
73+ }
74+
4975const isWordPressThemeDirectoryFallbackEvidence = ( evidenceText : string ) =>
5076 / (?: 资 源 或 源 码 路 径 包 含 | 动 态 资 源 路 径 包 含 ) / i. test ( evidenceText ) && / \/ w p - c o n t e n t \/ t h e m e s \/ / i. test ( evidenceText )
5177
@@ -117,7 +143,7 @@ export const suppressWordPressThemeDirectoryFallbacks = (items: any[]) => {
117143export const mergeTechnologyRecords = ( items : any [ ] ) => {
118144 const map = new Map < string , any > ( )
119145 for ( const item of suppressDuplicateWebsiteProgramCategories (
120- suppressWordPressThemeDirectoryFallbacks ( suppressFrontendFallbackDuplicates ( items ) )
146+ suppressWordPressThemeDirectoryFallbacks ( canonicalizeFrontendAliasTechnologies ( suppressFrontendFallbackDuplicates ( items ) ) )
121147 ) ) {
122148 const key = `${ item . category } ::${ item . name } ` . toLowerCase ( )
123149 const current = map . get ( key ) || { ...item , evidence : [ ] }
0 commit comments