diff options
author | Janis Altherr <jaltherr@gitlab.com> | 2021-12-02 14:02:14 +0300 |
---|---|---|
committer | Janis Altherr <jaltherr@gitlab.com> | 2021-12-02 14:02:14 +0300 |
commit | 810fd5987a636c201144d9ff3fd017718d68b48e (patch) | |
tree | 7e19de2577efa911c216236b4b3aab7994f933c8 | |
parent | a80fdd4bc37ab2521ac90a741d9254335ec91ac3 (diff) |
Improve comments and code readability668-allow-customizing-the-artifacts-path-public-in-gitlab-pages
-rw-r--r-- | internal/vfs/zip/archive.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/vfs/zip/archive.go b/internal/vfs/zip/archive.go index 8bbfaf8e..b37751ed 100644 --- a/internal/vfs/zip/archive.go +++ b/internal/vfs/zip/archive.go @@ -205,18 +205,23 @@ func (a *zipArchive) getAllRootDirectories() []string { } func (a *zipArchive) guessPublicDirectoryName() string { + rootDirectories := a.getAllRootDirectories() + + // If there's only one directory, use that, no matter what + if len(rootDirectories) == 1 { + return rootDirectories[0] + } + + // If there's multiple directories, perform an educated guess + // as to which is the public folder based on its name commonPrefixes := []string{ - // A slice of folder names used by popular SSG Frameworks + // Folder names used by popular SSG Frameworks "public", // previous GitLab behaviour, Hugo, Gatsby, Svelte // Non-default folder names, ordered by popularity "build", // React "dist", // Vue, Nuxt.js, Angular, Astro, Vite "out", // Next.js - "_site", // Eleventy - } - rootDirectories := a.getAllRootDirectories() - if len(rootDirectories) == 1 { - return rootDirectories[0] + "_site", // Eleventy, Jekyll } for _, pref := range commonPrefixes { if sliceContains(rootDirectories, pref) { |