| Server IP : 159.203.156.69 / Your IP : 216.73.216.28 Web Server : nginx/1.24.0 System : Linux main-ubuntu 6.8.0-71-generic #71-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 16:52:38 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/tanviranik.com/node_modules/unpic/script/src/providers/ |
Upload File : |
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transform = exports.extract = exports.generate = void 0;
const utils_js_1 = require("../utils.js");
const STORAGE_URL_PREFIX = "/storage/v1/object/public/";
const RENDER_URL_PREFIX = "/storage/v1/render/image/public/";
const isRenderUrl = (url) => url.pathname.startsWith(RENDER_URL_PREFIX);
const { operationsGenerator, operationsParser } = (0, utils_js_1.createOperationsHandlers)({});
const generate = (src, operations) => {
const url = (0, utils_js_1.toUrl)(src);
const basePath = url.pathname.replace(RENDER_URL_PREFIX, STORAGE_URL_PREFIX);
// Update the pathname with the cleaned version
url.pathname = basePath;
// Supabase uses auto-format unless set to origin. Specific formats are not supported
if (operations.format && operations.format !== "origin") {
delete operations.format;
}
// Add query parameters for image transformation
url.search = operationsGenerator(operations);
// Replace with the render prefix for rendering
return (0, utils_js_1.toCanonicalUrlString)(url).replace(STORAGE_URL_PREFIX, RENDER_URL_PREFIX);
};
exports.generate = generate;
const extract = (url) => {
const parsedUrl = (0, utils_js_1.toUrl)(url);
const operations = operationsParser(parsedUrl);
const isRender = isRenderUrl(parsedUrl);
const imagePath = parsedUrl.pathname.replace(RENDER_URL_PREFIX, "").replace(STORAGE_URL_PREFIX, "");
if (!isRender) {
return {
src: (0, utils_js_1.toCanonicalUrlString)(parsedUrl),
operations,
};
}
return {
src: `${parsedUrl.origin}${STORAGE_URL_PREFIX}${imagePath}`,
operations,
};
};
exports.extract = extract;
exports.transform = (0, utils_js_1.createExtractAndGenerate)(exports.extract, exports.generate);