GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
File: //usr/local/lib/node_modules/firebase-tools/lib/shortenUrl.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.shortenUrl = void 0;
const logger_1 = require("./logger");
const apiv2_1 = require("./apiv2");
const api_1 = require("./api");
const DYNAMIC_LINKS_PREFIX = "https://firebase.tools/l";
const apiClient = new apiv2_1.Client({
    urlPrefix: (0, api_1.dynamicLinksOrigin)(),
    auth: false,
    apiVersion: "v1",
});
async function shortenUrl(url, guessable = false) {
    try {
        const response = await apiClient.post(`shortLinks?key=${(0, api_1.dynamicLinksKey)()}`, {
            dynamicLinkInfo: {
                link: url,
                domainUriPrefix: DYNAMIC_LINKS_PREFIX,
            },
            suffix: { option: guessable ? "SHORT" : "UNGUESSABLE" },
        });
        return response.body.shortLink;
    }
    catch (e) {
        logger_1.logger.debug("URL shortening failed, falling back to full URL. Error:", e.original || e);
        return url;
    }
}
exports.shortenUrl = shortenUrl;