diff --git a/services/repository/files/content.go b/services/repository/files/content.go index 31827e8846e..6f6dc91d859 100644 --- a/services/repository/files/content.go +++ b/services/repository/files/content.go @@ -214,7 +214,9 @@ func GetContents(ctx context.Context, repo *repo_model.Repository, treePath, ref if err != nil { return nil, err } - contentsResponse.SubmoduleGitURL = &submodule.URL + if submodule != nil && submodule.URL != "" { + contentsResponse.SubmoduleGitURL = &submodule.URL + } } // Handle links if entry.IsRegular() || entry.IsLink() {