Skip to content

Commit cee0f1f

Browse files
committed
fix: use variable for regex in share link validation to avoid bash syntax error
The & character in the regex pattern caused a 'syntax error in conditional expression: unexpected token &' when used directly in [[ =~ ]]. Storing the pattern in a variable first is the correct bash idiom for regex matching.
1 parent 4063002 commit cee0f1f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

.github/workflows/validation.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ jobs:
156156
REPOSITORY: ${{ needs.parse-issue.outputs.repository }}
157157
run: |
158158
share_link=$(docker extension share "$REPOSITORY")
159-
if [[ ! "$share_link" =~ ^https://[a-zA-Z0-9./?=_&%-]+$ ]]; then
159+
url_regex='^https://[a-zA-Z0-9./?=_&%-]+$'
160+
if [[ ! "$share_link" =~ $url_regex ]]; then
160161
echo "Unexpected share link format" >> "$GITHUB_STEP_SUMMARY"
161162
exit 1
162163
fi

0 commit comments

Comments
 (0)