xref: /expo/docs/ui/components/Footer/utils.ts (revision bfbbd417)
1export function githubUrl(path: string) {
2  if (path === '/versions/latest' || path === '/versions/unversioned') {
3    path = '/versions/unversioned/index';
4  } else if (path === '/eas' || path === '/eas/') {
5    path = '/eas/index';
6  } else if (path === '/feature-preview' || path === '/feature-preview/') {
7    path = '/feature-preview/index';
8  }
9
10  if (path.includes('/versions/latest/')) {
11    path = path.replace('/versions/latest/', '/versions/unversioned/');
12  } else if (path.match(/v\d+\.\d+\.\d+\/?$/) || path === '/') {
13    if (path[path.length - 1] === '/') {
14      path = `${path}index`;
15    } else {
16      path = `${path}/index`;
17    }
18  }
19
20  const filePath =
21    path.replace(/\/$/, '').replace('/versions/latest', '/versions/unversioned') + '.mdx';
22
23  return `https://github.com/expo/expo/edit/main/docs/pages${filePath}`;
24}
25