@@ -15,27 +15,21 @@ const SUPPORT_PARAMS = [
1515] ;
1616
1717function calculateMatchScore (
18- { github, npmPkg, topicSearchString, unmaintained, githubUrl, vegaos } : LibraryType ,
18+ { github, npmPkg, topicSearchString, unmaintained, githubUrl, vegaos, score , npm } : LibraryType ,
1919 querySearch : string
2020) {
2121 const exactNameMatchPoints =
2222 ( ! isEmptyOrNull ( github . name ) && github . name . toLowerCase ( ) === querySearch ) ||
2323 ( ! isEmptyOrNull ( githubUrl ) && githubUrl . toLowerCase ( ) === querySearch ) ||
2424 ( ! isEmptyOrNull ( npmPkg ) && npmPkg . toLowerCase ( ) === querySearch )
25- ? 300
25+ ? 150
2626 : 0 ;
2727
2828 const npmPkgNameMatchPoints =
2929 ! isEmptyOrNull ( npmPkg ) &&
3030 ( npmPkg . includes ( querySearch ) ||
3131 npmPkg . replaceAll ( NPM_NAME_CLEANUP_REGEX , ' ' ) . toLowerCase ( ) . includes ( querySearch ) )
32- ? 200
33- : 0 ;
34-
35- const gitHubURLOrOwnerMatchPoints =
36- githubUrl . startsWith ( querySearch ) ||
37- githubUrl . replace ( GITHUB_URL_CLEANUP_REGEX , '$1' ) . toLowerCase ( ) . includes ( querySearch )
38- ? 150
32+ ? 125
3933 : 0 ;
4034
4135 const cleanedUpName = npmPkg
@@ -52,11 +46,17 @@ function calculateMatchScore(
5246 ? 100
5347 : 0 ;
5448
49+ const gitHubURLOrOwnerMatchPoints =
50+ githubUrl . startsWith ( querySearch ) ||
51+ githubUrl . replace ( GITHUB_URL_CLEANUP_REGEX , '$1' ) . toLowerCase ( ) . includes ( querySearch )
52+ ? 50
53+ : 0 ;
54+
5555 const repoNameMatchPoints =
5656 ! isEmptyOrNull ( github . name ) && github . name . toLowerCase ( ) . includes ( querySearch ) ? 50 : 0 ;
5757
5858 const vegaOSPackageMatchPoints =
59- typeof vegaos === 'string' && vegaos . includes ( querySearch ) ? 50 : 0 ;
59+ typeof vegaos === 'string' && vegaos . includes ( querySearch ) ? 25 : 0 ;
6060
6161 const descriptionMatchPoints =
6262 ! isEmptyOrNull ( github . description ) && github . description ?. toLowerCase ( ) . includes ( querySearch )
@@ -77,8 +77,10 @@ function calculateMatchScore(
7777
7878 if ( matchScore && unmaintained ) {
7979 return matchScore / 1000 ;
80+ } else if ( npm ?. downloads && npm . downloads < 10_000 ) {
81+ return matchScore / 10 ;
8082 } else {
81- return matchScore ;
83+ return matchScore > 0 ? matchScore + score / 2 : matchScore ;
8284 }
8385}
8486
0 commit comments