@@ -26,16 +26,21 @@ export type MatchAssetOpts = {
26
26
*/
27
27
version : string
28
28
/**
29
- * The keywords that must be in the asset name
29
+ * The keywords that must be in the asset name.
30
+ * If the element is a string, the keyword must be in the asset name.
31
+ * If the element is an array, one of the keywords must be in the asset name.
30
32
* @default []
31
33
*/
32
- keywords ?: string [ ]
34
+ keywords ?: ( string | string [ ] ) [ ]
33
35
/**
34
36
* Optional keywords that are not required to be in the asset name
35
37
* but increase the score of the asset if they are present
38
+ *
39
+ * if the element is a string, the keyword must be in the asset name
40
+ * if the element is an array, one of the keywords must be in the asset name
36
41
* @default []
37
42
*/
38
- optionalKeywords ?: string [ ]
43
+ optionalKeywords ?: ( string | string [ ] ) [ ]
39
44
/**
40
45
* Custom version compare function
41
46
* @param candidate The candidate version
@@ -158,7 +163,17 @@ function matchAssetName(tag: string, assetNames: string[], opts: MatchAssetOpts)
158
163
&& opts . keywords . length !== 0
159
164
) {
160
165
for ( const name of assetNames ) {
161
- if ( opts . keywords ! . every ( ( keyword ) => name . includes ( keyword ) ) ) {
166
+ if (
167
+ opts . keywords . every ( ( keyword ) => {
168
+ // single keyword
169
+ if ( typeof keyword === "string" && name . includes ( keyword ) ) {
170
+ return true
171
+ }
172
+ // keyword choices
173
+ return Array . isArray ( keyword )
174
+ && keyword . some ( ( k ) => name . includes ( k ) )
175
+ } )
176
+ ) {
162
177
candidates . push ( name )
163
178
}
164
179
}
@@ -179,7 +194,11 @@ function matchAssetName(tag: string, assetNames: string[], opts: MatchAssetOpts)
179
194
const candidateScores = candidates . map ( ( name ) => {
180
195
let score = 0
181
196
for ( const keyword of opts . optionalKeywords ! ) {
182
- if ( name . includes ( keyword ) ) {
197
+ // single keyword
198
+ if ( typeof keyword === "string" && name . includes ( keyword ) ) {
199
+ score ++
200
+ } // keyword choices
201
+ else if ( Array . isArray ( keyword ) && keyword . some ( ( k ) => name . includes ( k ) ) ) {
183
202
score ++
184
203
}
185
204
}
0 commit comments