diff --git a/claude-notion/bin/task-work b/claude-notion/bin/task-work index 58756e2..fb32134 100755 --- a/claude-notion/bin/task-work +++ b/claude-notion/bin/task-work @@ -85,7 +85,11 @@ fi [[ ${#POSITIONAL[@]} -lt 1 ]] && usage is_notion_url() { - [[ "$1" == *"notion.so"* || "$1" == *"notion.site"* ]] + # Anchored to the URL host so a free-form slug that merely contains the text + # (e.g. "my-notion.com-feature") is not misclassified as a URL. Allows any + # subdomain (www., app., or a published-site workspace) so the original + # *.notion.site behavior is preserved. (#158) + [[ "$1" =~ ^https?://([a-zA-Z0-9-]+\.)*notion\.(so|site|com)/ ]] } derive_slug_from_url() { diff --git a/kiro-notion/bin/task-work b/kiro-notion/bin/task-work index 921f006..8a6f7fe 100755 --- a/kiro-notion/bin/task-work +++ b/kiro-notion/bin/task-work @@ -91,7 +91,11 @@ done [[ ${#POSITIONAL[@]} -lt 1 ]] && usage is_notion_url() { - [[ "$1" == *"notion.so"* || "$1" == *"notion.site"* ]] + # Anchored to the URL host so a free-form slug that merely contains the text + # (e.g. "my-notion.com-feature") is not misclassified as a URL. Allows any + # subdomain (www., app., or a published-site workspace) so the original + # *.notion.site behavior is preserved. (#158) + [[ "$1" =~ ^https?://([a-zA-Z0-9-]+\.)*notion\.(so|site|com)/ ]] } derive_slug_from_url() { diff --git a/tests/claude_notion_task_work.bats b/tests/claude_notion_task_work.bats index 8d7eac9..432e2f3 100644 --- a/tests/claude_notion_task_work.bats +++ b/tests/claude_notion_task_work.bats @@ -53,6 +53,36 @@ teardown() { assert [ -d "$WORKTREE_BASE/my-explicit-slug" ] } +@test "app.notion.com single-arg: derives slug from title segment (#158)" { + run "$CLAUDE_NOTION_TASK_WORK" "https://app.notion.com/My-Feature-abc123def456abc123def456abc123de" + assert_success + assert [ -d "$WORKTREE_BASE/my-feature" ] +} + +@test "app.notion.com : records NOTION_URL in .info (#158)" { + local url="https://app.notion.com/My-Feature-abc123def456abc123def456abc123de" + run "$CLAUDE_NOTION_TASK_WORK" my-feature "$url" + assert_success + source "$WORKTREE_BASE/.my-feature.info" + assert_equal "$NOTION_URL" "$url" +} + +@test "false-positive guard: slug containing 'notion.com' resolves URL, not slug (#158)" { + # A free-form slug that merely contains "notion.com" must NOT be treated as a + # URL — the real app.notion.com arg must win and land in NOTION_URL. + local url="https://app.notion.com/Real-Page-abc123def456abc123def456abc123de" + run "$CLAUDE_NOTION_TASK_WORK" "my-notion.com-feature" "$url" + assert_success + source "$WORKTREE_BASE/.my-notioncom-feature.info" + assert_equal "$NOTION_URL" "$url" +} + +@test "notion.site subdomain URL still recognized (#158)" { + run "$CLAUDE_NOTION_TASK_WORK" "https://myworkspace.notion.site/My-Feature-abc123def456abc123def456abc123de" + assert_success + assert [ -d "$WORKTREE_BASE/my-feature" ] +} + # --------------------------------------------------------------------------- # Worktree + branch creation # --------------------------------------------------------------------------- diff --git a/tests/kiro_task_work.bats b/tests/kiro_task_work.bats index e1217ca..4058f29 100644 --- a/tests/kiro_task_work.bats +++ b/tests/kiro_task_work.bats @@ -53,6 +53,36 @@ teardown() { assert [ -d "$WORKTREE_BASE/my-explicit-slug" ] } +@test "app.notion.com single-arg: derives slug from title segment (#158)" { + run "$KIRO_TASK_WORK" "https://app.notion.com/My-Feature-abc123def456abc123def456abc123de" + assert_success + assert [ -d "$WORKTREE_BASE/my-feature" ] +} + +@test "app.notion.com : records NOTION_URL in .info (#158)" { + local url="https://app.notion.com/My-Feature-abc123def456abc123def456abc123de" + run "$KIRO_TASK_WORK" my-feature "$url" + assert_success + source "$WORKTREE_BASE/.my-feature.info" + assert_equal "$NOTION_URL" "$url" +} + +@test "false-positive guard: slug containing 'notion.com' resolves URL, not slug (#158)" { + # A free-form slug that merely contains "notion.com" must NOT be treated as a + # URL — the real app.notion.com arg must win and land in NOTION_URL. + local url="https://app.notion.com/Real-Page-abc123def456abc123def456abc123de" + run "$KIRO_TASK_WORK" "my-notion.com-feature" "$url" + assert_success + source "$WORKTREE_BASE/.my-notioncom-feature.info" + assert_equal "$NOTION_URL" "$url" +} + +@test "notion.site subdomain URL still recognized (#158)" { + run "$KIRO_TASK_WORK" "https://myworkspace.notion.site/My-Feature-abc123def456abc123def456abc123de" + assert_success + assert [ -d "$WORKTREE_BASE/my-feature" ] +} + # --------------------------------------------------------------------------- # Worktree + branch creation # ---------------------------------------------------------------------------