# Smart Git URL Parsing for Repository Creation ## Problem When users add a new repository, they often paste a full browser URL that includes branch names, file paths, or query parameters instead of a clean repository URL. This causes the clone operation to fail with unclear error messages. **Examples of problematic URLs:** - `https://github.com/user/repo/tree/main` (includes branch path) - `https://github.com/user/repo/blob/main/README.md` (includes file path) - `https://github.com/user/repo?tab=readme-ov-file` (includes query params) - `https://github.com/user/repo/pull/123` (includes PR path) **Current behavior:** The backend attempts to clone the exact URL, which fails with "fatal: repository not found" or similar errors. **User confusion:** Users don't understand why the clone failed since the URL works in their browser. ## Solution Implement smart URL parsing that: 1. **Detects non-repo URLs**: Recognizes when a URL contains paths like `/tree/`, `/blob/`, `/pull/`, or query parameters 2. **Extracts base repo URL**: Strips away branch names, file paths, query parameters to get `https://host/owner/repo.git` 3. **Suggests correction**: Shows the user the extracted base URL and asks for confirmation 4. **Improves clone handling**: Handles edge cases and provides clear error messages ## Benefits - **Better UX**: Users get helpful suggestions instead of cryptic errors - **Fewer support issues**: Self-service correction reduces confusion - **More robust**: Handles common copy-paste mistakes automatically - **Educational**: Teaches users what a proper git URL looks like ## Scope ### Backend - URL parsing utilities to detect and extract base repo URLs - Enhanced validation in repository creation endpoint - Clear error messages for unsupported URLs ### Frontend - UI dialog to show URL correction suggestions - Option to accept or edit the suggested URL - Visual indicator for URL validation status