Path: blob/master/src/packages/next/lib/share/proxy/get-public-path-info-gist.ts
1451 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45// provided by nextjs: https://nextjs.org/blog/next-9-4#improved-built-in-fetch-support6declare var fetch;78import { RAW_MAX_SIZE_BYTES } from "./api";910export default async function getPublicPathInfoGist(11url: string // 'gist/user/gistId'12) {13const v = url.split("/");14if (v.length < 3) {15throw Error(`invalid gist url - "${url}"`);16}17const [_, user, gistId] = v;18const rawUrl = `https://gist.githubusercontent.com/${user}/${gistId}/raw/`;19const content = await (await fetch(rawUrl, { size: RAW_MAX_SIZE_BYTES })).text();20return {21contents: { content, size: content.length },22relativePath: "",23projectTitle: `${user}'s GitHub Gists -- https://gist.github.com/${user}`,24githubOrg: user,25};26}272829