From cf1e5a95bbf8643d6721b8baf30cffc915ab89b4 Mon Sep 17 00:00:00 2001 From: Kir_Antipov Date: Sat, 20 May 2023 15:27:49 +0300 Subject: [PATCH] Added `id` validation to CurseForge and Modrinth uploaders --- src/platforms/curseforge/curseforge-uploader.ts | 3 +++ src/platforms/modrinth/modrinth-uploader.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/platforms/curseforge/curseforge-uploader.ts b/src/platforms/curseforge/curseforge-uploader.ts index ed4e1cf..3b1b041 100644 --- a/src/platforms/curseforge/curseforge-uploader.ts +++ b/src/platforms/curseforge/curseforge-uploader.ts @@ -2,6 +2,7 @@ import { CurseForgeUploadRequest as UploadRequest, CurseForgeUploadReport as Upl import { Dependency } from "@/dependencies"; import { PlatformType } from "@/platforms/platform-type"; import { GenericPlatformUploader, GenericPlatformUploaderOptions } from "@/platforms/generic-platform-uploader"; +import { ArgumentError } from "@/utils/errors"; import { CurseForgeDependency } from "./curseforge-dependency"; import { CurseForgeDependencyType } from "./curseforge-dependency-type"; import { CurseForgeEternalApiClient } from "./curseforge-eternal-api-client"; @@ -48,6 +49,8 @@ export class CurseForgeUploader extends GenericPlatformUploader { + ArgumentError.throwIfNullOrEmpty(request.id, "request.id"); + const api = new CurseForgeUploadApiClient({ token: request.token.unwrap() }); const eternalApi = new CurseForgeEternalApiClient(); diff --git a/src/platforms/modrinth/modrinth-uploader.ts b/src/platforms/modrinth/modrinth-uploader.ts index 3ece999..0859bcd 100644 --- a/src/platforms/modrinth/modrinth-uploader.ts +++ b/src/platforms/modrinth/modrinth-uploader.ts @@ -4,6 +4,7 @@ import { GenericPlatformUploader, GenericPlatformUploaderOptions } from "@/platf import { PlatformType } from "@/platforms/platform-type"; import { $i } from "@/utils/collections"; import { IGNORE_CASE_AND_NON_WORD_CHARACTERS_EQUALITY_COMPARER } from "@/utils/comparison"; +import { ArgumentError } from "@/utils/errors"; import { ModrinthApiClient } from "./modrinth-api-client"; import { ModrinthDependency } from "./modrinth-dependency"; import { ModrinthDependencyType } from "./modrinth-dependency-type"; @@ -50,6 +51,8 @@ export class ModrinthUploader extends GenericPlatformUploader { + ArgumentError.throwIfNullOrEmpty(request.id, "request.id"); + const api = new ModrinthApiClient({ token: request.token.unwrap() }); const unfeatureMode = request.unfeatureMode ?? (request.featured ? ModrinthUnfeatureMode.SUBSET : ModrinthUnfeatureMode.NONE);