---
name: parse_git_url
kind: function
lang: py
domain: core
version: "1.0.0"
purity: pure
signature: "def parse_git_url(url: str, known_hosts: list[str] | None = None) -> str | None"
description: "Parsea una URL de code hosting (GitHub, GitLab, etc.) y retorna el path org/repo. Soporta HTTPS, HTTP, SSH (git@), git:// y ssh://."
tags: [git, url, parsing, github, gitlab, repository, pendiente-usar]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: [urllib.parse]
params:
  - name: url
    desc: "URL de repositorio de código (HTTPS, SSH, git://, ssh://)"
  - name: known_hosts
    desc: "Lista opcional de hosts conocidos a reconocer"
output: "String con formato 'org/repo' si la URL es válida, None si no se puede parsear"
tested: true
tests:
  - "URL HTTPS GitHub"
  - "URL SSH git@"
  - "URL con .git suffix"
  - "URL con path extra (issues/123)"
  - "URL no reconocida"
test_file_path: "python/functions/core/parse_git_url_test.py"
file_path: "python/functions/core/core.py"
---

## Ejemplo

```python
parse_git_url("https://github.com/psf/requests")
# "psf/requests"

parse_git_url("git@github.com:psf/requests.git")
# "psf/requests"

parse_git_url("https://github.com/psf/requests/issues/123")
# "psf/requests"  (ignora segmentos extra)

parse_git_url("https://bitbucket.org/org/repo")
# None  (host desconocido)
```

## Notas

Funcion pura. Sanitiza org y repo dejando solo `[a-zA-Z0-9_-]`. Los hosts por defecto son `github.com` y `gitlab.com`; se pueden extender via `known_hosts`. No hace requests de red.
