Skip to content

Commit 7570e02

Browse files
authored
Merge pull request #400 from Kuuuube/fix-max-version
Filter out plugin versions with max supported version lower than selected version and fix breakage if subversion gets to 10 or higher
2 parents ca39d23 + 8fc3d94 commit 7570e02

2 files changed

Lines changed: 34 additions & 10 deletions

File tree

‎site/_includes/filterjs.html‎

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
let card = cards[i];
4040
let name = card.getAttribute('data-name').toUpperCase();
4141
let version = card.getAttribute('data-version');
42+
let maxVersion = card.getAttribute('data-max-version');
4243

4344
if (!isCompatible(version, targetVersion))
4445
continue;
@@ -57,9 +58,10 @@
5758
let card = cards[i];
5859
let name = card.getAttribute('data-name').toUpperCase();
5960
let version = card.getAttribute('data-version');
61+
let maxVersion = card.getAttribute('data-max-version');
6062

6163
let searchMatches = name.indexOf(searchFilter) >= 0;
62-
let versionMatches = targetVersion == '' || isCompatible(version, targetVersion);
64+
let versionMatches = targetVersion == '' || isCompatible(version, targetVersion, maxVersion);
6365
let isNewest = true;
6466
if (name in versions) {
6567
isNewest = versions[name] == version;
@@ -69,26 +71,48 @@
6971
}
7072
}
7173

72-
function isCompatible(pluginVersion, driverVersion) {
74+
function isCompatible(pluginVersion, driverVersion, maxPluginVersion) {
7375
// support truth table:
7476
// plugin / driver
7577
// 0.5.3.3 and 0.6.0.0: false
7678
// 0.6.0.0 and 0.5.3.3: false
7779
// 0.5.2.0 and 0.5.3.3: true
7880
// 0.5.3.3 and 0.5.2.0: false
7981

80-
let pluginSplit = pluginVersion.split('.');
81-
let driverSplit = driverVersion.split('.');
82+
let pluginSplit = getIntSplit(pluginVersion);
83+
let maxPluginSplit = getIntSplit(maxPluginVersion);
84+
let driverSplit = getIntSplit(driverVersion);
8285

83-
if (pluginSplit[0] != driverSplit[0])
84-
return false;
86+
try {
87+
if (pluginSplit[0] != driverSplit[0] || (maxPluginSplit != null && maxPluginSplit[0] != driverSplit[0])) {
88+
return false;
89+
}
8590

86-
if (pluginSplit[1] != driverSplit[1])
87-
return false;
91+
if (pluginSplit[1] != driverSplit[1] || (maxPluginSplit != null && maxPluginSplit[1] != driverSplit[1])) {
92+
return false;
93+
}
94+
95+
if (pluginSplit[2] > driverSplit[2] || (maxPluginSplit != null && maxPluginSplit[2] < driverSplit[2])) {
96+
return false;
97+
}
8898

89-
if (pluginSplit[2] > driverSplit[2])
99+
// The final version number on a plugin's base version number is allowed through no matter what, this filtering is intentionally not applied:
100+
// pluginSplit[2] == driverSplit[2] && pluginSplit[3] > driverSplit[3]
101+
// Only the MaxSupportedPluginVersion is checked for the final version number
102+
if (maxPluginSplit != null && maxPluginSplit[2] == driverSplit[2] && maxPluginSplit[3] < driverSplit[3])
103+
return false;
104+
} catch (e) {
105+
console.error(`Failed to determine plugin version compatibility. Plugin version: ${pluginVersion}. Driver version: ${driverVersion}.\nError: ${e}`);
90106
return false;
107+
}
91108

92109
return true;
93110
}
111+
112+
function getIntSplit(inputString) {
113+
if (inputString)
114+
return inputString.split('.').map((x) => Number(x));
115+
116+
return null;
117+
}
94118
</script>

‎site/_layouts/plugins.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
{% endif %}
7878
{%- endcapture -%}
7979
<div class="card mb-2 plugin-metadata-card"
80-
data-name="{{ metadata.Name }}" data-version="{{ metadata.SupportedDriverVersion }}">
80+
data-name="{{ metadata.Name }}" data-version="{{ metadata.SupportedDriverVersion }}" data-max-version="{{ metadata.MaxSupportedDriverVersion }}">
8181
<div class="card-body d-flex flex-lg-row flex-column flex-wrap p-4 justify-content-end">
8282
<div class="flex-fill">
8383
<!-- version badges -->

0 commit comments

Comments
 (0)