def get_repository_config(self, name_or_url: str, prefix: str) -> RepositoryConfig | None:
        """Get a repository or source by name or url."""
        repositories: dict[str, RepositoryConfig] = {}
        for k, v in self._data.items():
            if not k.startswith(f"{prefix}.") or k in self._config_map:
                continue
            key = k[len(prefix) + 1 :]
            repositories[key] = RepositoryConfig(**v, name=key, config_prefix=prefix)
        config: RepositoryConfig | None = None
        if "://" in name_or_url:
            config = next(
                (v for v in repositories.values() if v.url == name_or_url),
                RepositoryConfig(url=name_or_url, name="__unknown__", config_prefix=prefix),
            )
        else:
            config = repositories.get(name_or_url)

        if prefix == SOURCE or not self.is_global:
            return config

        if name_or_url in DEFAULT_REPOSITORIES:
            if config is None:
                return RepositoryConfig(url=DEFAULT_REPOSITORIES[name_or_url], name=name_or_url, config_prefix=prefix)
            config.passive_update(url=DEFAULT_REPOSITORIES[name_or_url])
        if name_or_url in DEFAULT_REPOSITORIES.values():
            name = next(k for k, v in DEFAULT_REPOSITORIES.items() if v == name_or_url)
            if config is None:
                return RepositoryConfig(
                    name=name,
                    config_prefix=prefix,
                    url=name_or_url,
                )
            config.passive_update(url=name_or_url)
            if config.name == "__unknown__":
                config.name = name
        return config
Get a repository or source by name or url.
src/pdm/project/config.py