Skip to content

Commit bc29c5c

Browse files
authored
Merge pull request #77 from dacharyc/tweak-snooty-get-docs-logic
Handle unversioned docs with new Snooty Data API pattern
2 parents e5a8603 + c766983 commit bc29c5c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

audit/gdcd/snooty/GetProjects.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,16 @@ func GetProjects(client *http.Client) []types.ProjectDetails {
100100
// have double slashes.
101101
urlWithNoTrailingSlash := removeTrailingSlash(branch.FullUrl)
102102

103-
// A change in Snooty Data API behavior means the branch name from the projects endpoint is no longer
104-
// used to fetch the documents for that project. Instead, we should use the last segment of the URL.
105-
version = getLastSegment(urlWithNoTrailingSlash)
103+
// If the docs project has only one branch, we can assume it's unversioned and just use "main" as
104+
// the version to fetch documents. i.e. https://www.mongodb.com/docs/mongodb-shell/
105+
if len(docsProject.Branches) == 1 {
106+
version = "main"
107+
} else {
108+
// If the docs project has more than one branch, we need to use the active, stable branch name's
109+
// last segment of the URL as the version to fetch documents. i.e. https://www.mongodb.com/docs/atlas/operator/current/
110+
lastSegment := getLastSegment(urlWithNoTrailingSlash)
111+
version = lastSegment
112+
}
106113
prodUrl = urlWithNoTrailingSlash
107114
break
108115
}

0 commit comments

Comments
 (0)