26 lines
682 B
Python
26 lines
682 B
Python
# Copyright (c) 2025 Patrick Motsch
|
|
# All rights reserved.
|
|
"""Parse virtual ClickUp paths used by the connector."""
|
|
|
|
import re
|
|
from typing import Optional, Tuple
|
|
|
|
|
|
def parse_team_and_list(path: str) -> Tuple[Optional[str], Optional[str]]:
|
|
p = (path or "").strip()
|
|
m = re.match(r"^/team/([^/]+)/list/([^/]+)$", p)
|
|
if m:
|
|
return m.group(1), m.group(2)
|
|
return None, None
|
|
|
|
|
|
def parse_task_id(path_or_id: str) -> Optional[str]:
|
|
s = (path_or_id or "").strip()
|
|
if not s:
|
|
return None
|
|
m = re.match(r"^.*/task/([^/]+)$", s)
|
|
if m:
|
|
return m.group(1)
|
|
if re.match(r"^[a-zA-Z0-9_-]+$", s) and len(s) > 4:
|
|
return s
|
|
return None
|