Skip to content

Commit 46b401e

Browse files
committed
fix: support fuzzy match
1 parent c25401a commit 46b401e

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

hooks/pre_use.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
local distribution_version_parser = require("distribution_version")
22

33
function PLUGIN:PreUse(ctx)
4-
local distribution_version = distribution_version_parser.parse_version(ctx.version)
4+
local input_version = ctx.version
5+
local distribution_version = distribution_version_parser.parse_version(input_version)
6+
7+
-- If it is a pure numeric major version (such as "8"), and the distribution is openjdk, let the core perform fuzzy matching.
8+
if distribution_version and distribution_version.distribution.short_name == "open" then
9+
if not string.find(distribution_version.version, "%.") then -- Pure numbers, no minor versions
10+
return "" -- Return empty, let vfox core perform fuzzy matching
11+
end
12+
end
13+
14+
515
if distribution_version and distribution_version.distribution.short_name ~= "open" then
616
return {
717
version = distribution_version.version .. "-" .. distribution_version.distribution.short_name
818
}
919
else
1020
return {
11-
version = ctx.version,
21+
version = input_version,
1222
}
1323
end
14-
end
15-
24+
end

0 commit comments

Comments
 (0)