Path: blob/master/src/packages/next/lib/share/proxy/get-proxied-public-path-info.ts
1451 views
// Get public path info for public path defined by url proxy which is assumed1// to already exist in the database.23import getPublicPathInfoGithub from "./get-public-path-info-github";4import getPublicPathInfoGist from "./get-public-path-info-gist";5import { join } from "path";67// disabled -- see comment below8// import getPublicPathInfoUrl from "./get-public-path-info-url";910export default async function getProxiedPublicPathInfo(11url: string,12segments?: string[]13) {14if (url.startsWith("github/")) {15return await getPublicPathInfoGithub(16segments == null ? url : join(url, ...segments.slice(1))17);18}19if (url.startsWith("gist/")) {20return await getPublicPathInfoGist(url);21}22// This is disabled now since it is easy for spammers to take advantage of this,23// and also when people paste general URL's in they are almost never the actual24// raw url of a notebook, but instead a general HTML page that has something like25// a notebook in it, and they just get confused.26// if (url.startsWith("url/")) {27// return await getPublicPathInfoUrl(url);28// }29throw Error(30`unsupported proxy url schema -- "${url}" -- url must be hosted on GitHub`31);32}333435