Skip to content

Commit

Permalink
Remove duplicate versions
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKahr committed Jun 5, 2024
1 parent 7904263 commit aa997c2
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions functions/src/logic/ingestUnityVersions/scrapeVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,28 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
if (script.textContent) {
const matches = [...script.textContent.matchAll(unity_version_regex)];
if (matches.length > 0) {
const uniqueVersions = new Set<string>();
return matches
.filter((match) => {
// Filter out prerelease versions
return match[3].includes('f');
})
.map((match) => {
const [_, major, minor, patch, changeSet] = match;
return {
version: `${major}.${minor}.${patch}`,
major: Number(major),
minor: Number(minor),
patch,
changeSet,
};
});
const version = `${major}.${minor}.${patch}`;
if (!uniqueVersions.has(version)) {
uniqueVersions.add(version);
return {
version,
major: Number(major),
minor: Number(minor),
patch,
changeSet,
};
}
return null;
})
.filter((version) => version !== null) as EditorVersionInfo[];
}
}
}
Expand Down

0 comments on commit aa997c2

Please sign in to comment.