Skip to content

Commit fe20df7

Browse files
authored
Fix unity versions scrapping not getting all the versions (#54)
1 parent e3d917f commit fe20df7

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

functions/src/logic/ingestUnityVersions/scrapeVersions.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
99

1010
const scripts = document.querySelectorAll('script');
1111

12+
const allVersions = new Map<string, EditorVersionInfo>();
13+
1214
for (const script of scripts) {
1315
if (script.textContent) {
1416
const matches = [...script.textContent.matchAll(unity_version_regex)];
1517
if (matches.length > 0) {
16-
const uniqueVersions = new Set<string>();
17-
return matches
18+
const versions = matches
1819
.filter((match) => {
1920
// Filter out prerelease and unsupported versions
2021
const [_, major, minor, patch, changeSet] = match;
@@ -23,8 +24,7 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
2324
.map((match) => {
2425
const [_, major, minor, patch, changeSet] = match;
2526
const version = `${major}.${minor}.${patch}`;
26-
if (!uniqueVersions.has(version)) {
27-
uniqueVersions.add(version);
27+
if (!allVersions.has(version)) {
2828
return {
2929
version,
3030
changeSet,
@@ -38,9 +38,17 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
3838
return null;
3939
})
4040
.filter((version) => version !== null) as EditorVersionInfo[];
41+
42+
versions.forEach((it) => {
43+
allVersions.set(it.version, it);
44+
});
4145
}
4246
}
4347
}
4448

49+
if (allVersions.size > 0) {
50+
return Array.from(allVersions.values());
51+
}
52+
4553
throw new Error('No Unity versions found!');
4654
};

0 commit comments

Comments
 (0)