From db259dd0f375fbcde8b922124dde736ff030d8e9 Mon Sep 17 00:00:00 2001 From: Gabriel Adrian Samfira Date: Mon, 18 Dec 2023 15:47:09 +0000 Subject: [PATCH] Account for trailing slash Fix the regex so that it will match callback URLs that end with status/. Normally, the "/status" suffix should not be added. This is a convenience check that allows users time to adapt their configs to the new URL. Signed-off-by: Gabriel Adrian Samfira --- cloudconfig/templates.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudconfig/templates.go b/cloudconfig/templates.go index f813e5f..d3cb660 100644 --- a/cloudconfig/templates.go +++ b/cloudconfig/templates.go @@ -43,7 +43,7 @@ fi function call() { PAYLOAD="$1" - [[ $CALLBACK_URL =~ ^(.*)/status$ ]] || CALLBACK_URL="${CALLBACK_URL}/status" + [[ $CALLBACK_URL =~ ^(.*)/status(/)?$ ]] || CALLBACK_URL="${CALLBACK_URL}/status" curl --retry 5 --retry-delay 5 --retry-connrefused --fail -s -X POST -d "${PAYLOAD}" -H 'Accept: application/json' -H "Authorization: Bearer ${BEARER_TOKEN}" "${CALLBACK_URL}" || echo "failed to call home: exit code ($?)" } @@ -386,7 +386,7 @@ $GHRunnerGroup = "{{.GitHubRunnerGroup}}" function Install-Runner() { $CallbackURL="{{.CallbackURL}}" - if (!$CallbackURL.EndsWith("/status")) { + if (!($CallbackURL -match "^(.*)/status(/)?$")) { $CallbackURL = "$CallbackURL/status" }