"use strict";
/*
 *  This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
 *  License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details
 */
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_fetch_1 = __importDefault(require("node-fetch"));
const api_1 = require("./api");
async function getPublicPathInfoGist(url // 'gist/user/gistId'
) {
    const v = url.split("/");
    if (v.length < 3) {
        throw Error(`invalid gist url - "${url}"`);
    }
    const [_, user, gistId] = v;
    const rawUrl = `https://gist.githubusercontent.com/${user}/${gistId}/raw/`;
    const content = await (await (0, node_fetch_1.default)(rawUrl, { size: api_1.RAW_MAX_SIZE_BYTES })).text();
    return {
        contents: { content, size: content.length },
        relativePath: "",
        projectTitle: `${user}'s GitHub Gists -- https://gist.github.com/${user}`,
        githubOrg: user,
    };
}
exports.default = getPublicPathInfoGist;
//# sourceMappingURL=get-public-path-info-gist.js.map