From 5b0dd6971ae94716f1095e22de1c558e56302c6b Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 15 Feb 2024 18:34:33 +0100 Subject: [PATCH] Add check of prefix and suffix input --- src/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/index.js b/src/index.js index 6883070..bda6df7 100644 --- a/src/index.js +++ b/src/index.js @@ -181,6 +181,20 @@ async function run() { const defaultTag = core.getInput("defaultTag"); const branchRegex = core.getInput("branchRegex"); + function check_prefix_suffix(input_name, input_value) { + // Partial check that prefix and suffix inputs are OK + // Check if there is any whitespace characters besides new lines or + // commas. + const re = new RegExp(/^[^\s,]+$/g); + if (re.test(input_value.replace("\n", ""))) { + throw new Error( + `Input ${input_name} invalid, contains either comma or whitespace besides the new line separator`, + ); + } + } + check_prefix_suffix("prefix", prefix); + check_prefix_suffix("suffix", suffix); + core.debug(JSON.stringify(github.context)); const allTags = await calculateTags({ token: githubToken,