Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 39317cf

Browse files
committed
Fixed Crash With Empty Submodules
1 parent c1eba1b commit 39317cf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

CodeHub.iOS/ViewControllers/Source/SourceTreeViewController.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,21 @@ private void GoToSourceTree(Octokit.RepositoryContent content)
228228

229229
private void GoToSubModule(Octokit.RepositoryContent content)
230230
{
231+
if (content == null)
232+
return;
233+
231234
var gitUrl = content.GitUrl;
232-
var nameAndSlug = gitUrl.Substring(gitUrl.IndexOf("/repos/", StringComparison.Ordinal) + 7);
235+
if (string.IsNullOrEmpty(gitUrl))
236+
return;
237+
238+
var repoDelimIndex = gitUrl.IndexOf("/repos/", StringComparison.Ordinal);
239+
if (repoDelimIndex < 0 || repoDelimIndex + 7 > gitUrl.Length)
240+
return;
241+
242+
var nameAndSlug = gitUrl.Substring(repoDelimIndex + 7);
233243
var indexOfGit = nameAndSlug.LastIndexOf("/git", StringComparison.Ordinal);
234244
indexOfGit = indexOfGit < 0 ? 0 : indexOfGit;
245+
235246
var repoId = RepositoryIdentifier.FromFullName(nameAndSlug.Substring(0, indexOfGit));
236247
if (repoId == null)
237248
return;

0 commit comments

Comments
 (0)