@@ -25,26 +25,40 @@ function calculateMatchScore(
2525 ? 150
2626 : 0 ;
2727
28- const npmPkgNameMatchPoints =
29- ! isEmptyOrNull ( npmPkg ) &&
30- ( npmPkg . includes ( querySearch ) ||
31- npmPkg . replaceAll ( NPM_NAME_CLEANUP_REGEX , ' ' ) . toLowerCase ( ) . includes ( querySearch ) )
32- ? 125
33- : 0 ;
34-
3528 const cleanedUpName = npmPkg
3629 . replace ( 'react-native' , '' )
3730 . replace ( 'react' , '' )
3831 . replaceAll ( NPM_NAME_CLEANUP_REGEX , ' ' )
3932 . toLowerCase ( )
4033 . trim ( ) ;
4134
35+ const cleanedUpQuery = querySearch
36+ . replace ( 'react-native' , '' )
37+ . replace ( 'react' , '' )
38+ . replaceAll ( NPM_NAME_CLEANUP_REGEX , ' ' )
39+ . trim ( ) ;
40+
41+ const queryTokens = cleanedUpQuery . split ( / \s + / ) . filter ( Boolean ) ;
42+ const allTokensMatch =
43+ queryTokens . length > 0 && queryTokens . every ( token => cleanedUpName . includes ( token ) ) ;
44+
45+ const npmPkgNameMatchPoints =
46+ ! isEmptyOrNull ( npmPkg ) &&
47+ ( npmPkg . includes ( querySearch ) ||
48+ npmPkg . replaceAll ( NPM_NAME_CLEANUP_REGEX , ' ' ) . toLowerCase ( ) . includes ( querySearch ) )
49+ ? 125
50+ : ! isEmptyOrNull ( npmPkg ) && allTokensMatch
51+ ? 100
52+ : 0 ;
53+
4254 const cleanedUpNameMatchPoints =
4355 ! isEmptyOrNull ( cleanedUpName ) &&
4456 ( cleanedUpName . includes ( querySearch ) ||
4557 cleanedUpName . includes ( querySearch . replaceAll ( NPM_NAME_CLEANUP_REGEX , ' ' ) ) )
4658 ? 100
47- : 0 ;
59+ : ! isEmptyOrNull ( cleanedUpName ) && allTokensMatch
60+ ? 75
61+ : 0 ;
4862
4963 const gitHubURLOrOwnerMatchPoints =
5064 githubUrl . startsWith ( querySearch ) ||
@@ -53,7 +67,11 @@ function calculateMatchScore(
5367 : 0 ;
5468
5569 const repoNameMatchPoints =
56- ! isEmptyOrNull ( github . name ) && github . name . toLowerCase ( ) . includes ( querySearch ) ? 50 : 0 ;
70+ ! isEmptyOrNull ( github . name ) && github . name . toLowerCase ( ) . includes ( querySearch )
71+ ? 50
72+ : ! isEmptyOrNull ( github . name ) && allTokensMatch
73+ ? 35
74+ : 0 ;
5775
5876 const vegaOSPackageMatchPoints =
5977 typeof vegaos === 'string' && vegaos . includes ( querySearch ) ? 25 : 0 ;
0 commit comments