Skip to content

Commit 2b20b68

Browse files
committed
use master branch
1 parent 3dd1e39 commit 2b20b68

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/lib/helpers/templateSource.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import type { Models } from '@appwrite.io/console';
22

33
/**
4-
* Example (GitHub): https://github.com/appwrite/templates-for-sites/tree/main/sveltekit/starter
4+
* build VCS repo URL from the template response model.
5+
* supports GitHub, GitLab, and Bitbucket.
6+
*
7+
* important: We use 'master' as the branch name because GitHub (and other providers)
8+
* redirect 'master' to the repository's default branch, regardless of whether
9+
* its actually named 'main', 'master', or something else. This ensures the
10+
* link works across all repositories without needing to know their default branch.
11+
*
12+
* Example (GitHub): https://github.com/appwrite/templates-for-sites/tree/master/sveltekit/starter
513
*/
614
export function getTemplateSourceUrl(
715
t: Models.TemplateSite | Models.TemplateFunction
@@ -44,12 +52,13 @@ export function getTemplateSourceUrl(
4452
const normalizedPath = folderPath.replace(/^\/+|\/+$/g, '');
4553
if (normalizedPath) {
4654
const providerLower = provider.toLowerCase();
55+
// Use 'master' as branch name - GitHub/GitLab/Bitbucket redirect it to default branch
4756
if (providerLower === 'github') {
48-
url = `${url}/tree/main/${normalizedPath}`;
57+
url = `${url}/tree/master/${normalizedPath}`;
4958
} else if (providerLower === 'gitlab') {
50-
url = `${url}/-/tree/main/${normalizedPath}`;
59+
url = `${url}/-/tree/master/${normalizedPath}`;
5160
} else if (providerLower === 'bitbucket') {
52-
url = `${url}/src/main/${normalizedPath}`;
61+
url = `${url}/src/master/${normalizedPath}`;
5362
}
5463
}
5564
}

0 commit comments

Comments
 (0)