From 6273af503b1b4df22876b846d1bb9ef2e597ce90 Mon Sep 17 00:00:00 2001 From: Thomas Camlong Date: Mon, 30 Oct 2023 16:24:48 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20walks=20repository=20not?= =?UTF-8?q?=20up=20to=20date?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/images/github-icons-repository.ts | 15 +++++++++++++-- .../server/images/jsdelivr-icons-repository.ts | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/tools/server/images/github-icons-repository.ts b/src/tools/server/images/github-icons-repository.ts index 2abb07d06..38e8f19e1 100644 --- a/src/tools/server/images/github-icons-repository.ts +++ b/src/tools/server/images/github-icons-repository.ts @@ -19,12 +19,23 @@ export class GitHubIconsRepository extends AbstractIconRepository { } protected async fetchInternally(): Promise { - const response = await fetch(this.repository.api); + const response = await fetch(this.repository.api, { + + }); const body = (await response.json()) as GitHubRepo; const normalizedEntries = body.tree - .filter((file) => !['_banner.png', '_logo.png'].some((x) => file.path.includes(x))) + .filter((file) => !['banner.png', 'logo.png'].some((x) => file.path.includes(x))) .filter((file) => ['.png', '.svg'].some((x) => file.path.endsWith(x))) + .sort((a, b) => { + if (a.path.endsWith('.svg') && b.path.endsWith('.png')) { + return -1; + } + if (a.path.endsWith('.png') && b.path.endsWith('.svg')) { + return 1; + } + return 0; + }) .map((file): NormalizedIcon => { const fileNameParts = file.path.split('/'); const fileName = fileNameParts[fileNameParts.length - 1]; diff --git a/src/tools/server/images/jsdelivr-icons-repository.ts b/src/tools/server/images/jsdelivr-icons-repository.ts index 737b1faa1..19cf7b164 100644 --- a/src/tools/server/images/jsdelivr-icons-repository.ts +++ b/src/tools/server/images/jsdelivr-icons-repository.ts @@ -28,8 +28,9 @@ export class JsdelivrIconsRepository extends AbstractIconRepository { const body = (await response.json()) as JsdelivrResponse; const normalizedEntries = body.files - .filter((file) => !['banner.png', 'logo.png'].some((x) => file.name.includes(x))) + .filter((file) => !['_banner.png', '_logo.png'].some((x) => file.name.includes(x))) .filter((file) => ['.png', '.svg'].some((x) => file.name.endsWith(x))) + .map((file): NormalizedIcon => { const fileNameParts = file.name.split('/'); const fileName = fileNameParts[fileNameParts.length - 1];