From d68a63af41897ec2bc93fbef6273294fee4e5c7f Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Mon, 6 Apr 2026 02:51:51 +0000 Subject: [PATCH] fix(kugetsu-session): extract_issue_ref_from_message fix URL parsing Fix issue where full URLs like https://git.fbrns.co/shoko/kugetsu/issues/158 were incorrectly parsed to 'shoko/kugetsu/issues#158' instead of 'git.fbrns.co/shoko/kugetsu#158'. The regex now correctly extracts instance, owner, repo, and number using bash regex capture groups instead of fragile sed/cut pipeline. --- skills/kugetsu/scripts/kugetsu-session.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/skills/kugetsu/scripts/kugetsu-session.sh b/skills/kugetsu/scripts/kugetsu-session.sh index 2ee1e89..764a096 100755 --- a/skills/kugetsu/scripts/kugetsu-session.sh +++ b/skills/kugetsu/scripts/kugetsu-session.sh @@ -156,13 +156,11 @@ extract_issue_ref_from_message() { return fi - if [[ "$message" =~ (https?://[a-zA-Z0-9.-]+/[a-zA-Z0-9._-]+/[a-zA-Z0-9._-]+/(issues|pull)/[0-9]+) ]]; then - local url="${BASH_REMATCH[1]}" - local path=$(echo "$url" | sed 's|https\?://||' | cut -d'/' -f2-) - local instance=$(echo "$path" | cut -d'/' -f1) - local owner=$(echo "$path" | cut -d'/' -f2) - local repo=$(echo "$path" | cut -d'/' -f3) - local num=$(echo "$path" | grep -oE '[0-9]+$') + if [[ "$message" =~ (https?://)?([a-zA-Z0-9.-]+)/([a-zA-Z0-9._-]+)/([a-zA-Z0-9._-]+)/(issues|pull)/([0-9]+) ]]; then + local instance="${BASH_REMATCH[2]}" + local owner="${BASH_REMATCH[3]}" + local repo="${BASH_REMATCH[4]}" + local num="${BASH_REMATCH[6]}" echo "${instance}/${owner}/${repo}#${num}" return fi