|
1 | 1 | import type { Models } from '@appwrite.io/console'; |
2 | 2 |
|
3 | 3 | /** |
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 |
5 | 13 | */ |
6 | 14 | export function getTemplateSourceUrl( |
7 | 15 | t: Models.TemplateSite | Models.TemplateFunction |
@@ -44,12 +52,13 @@ export function getTemplateSourceUrl( |
44 | 52 | const normalizedPath = folderPath.replace(/^\/+|\/+$/g, ''); |
45 | 53 | if (normalizedPath) { |
46 | 54 | const providerLower = provider.toLowerCase(); |
| 55 | + // Use 'master' as branch name - GitHub/GitLab/Bitbucket redirect it to default branch |
47 | 56 | if (providerLower === 'github') { |
48 | | - url = `${url}/tree/main/${normalizedPath}`; |
| 57 | + url = `${url}/tree/master/${normalizedPath}`; |
49 | 58 | } else if (providerLower === 'gitlab') { |
50 | | - url = `${url}/-/tree/main/${normalizedPath}`; |
| 59 | + url = `${url}/-/tree/master/${normalizedPath}`; |
51 | 60 | } else if (providerLower === 'bitbucket') { |
52 | | - url = `${url}/src/main/${normalizedPath}`; |
| 61 | + url = `${url}/src/master/${normalizedPath}`; |
53 | 62 | } |
54 | 63 | } |
55 | 64 | } |
|
0 commit comments