Path: blob/master/src/packages/next/lib/share/proxy/get-public-path-info-github.ts
1451 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import getContents from "./get-contents";6import { join } from "path";78export default async function getPublicPathInfoGithub(url: string) {9const segments = url.split("/");10const githubOrg = segments[1];11if (!githubOrg) {12throw Error(`invalid url ${url} -- must include github organization`);13}14const githubRepo = segments[2];15const relativePath = join(...segments.slice(3));1617if (!githubRepo) {18// only getting the repos for a single org.19const contents = await getContents(githubOrg, "", []);20const projectTitle = `GitHub Repositories owned by ${githubOrg}`;2122return {23contents,24relativePath,25projectTitle,26githubOrg,27};28}2930const contents = await getContents(githubOrg, githubRepo, segments.slice(3));31const projectTitle = `GitHub repository ${githubOrg} / ${githubRepo}`;3233return {34contents,35relativePath,36projectTitle,37githubOrg,38githubRepo,39url,40};41}424344