| 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 { operationsGenerator, operationsParser } = (0, utils_js_1.createOperationsHandlers)({
keyMap: {
width: "w",
height: "h",
format: "f",
quality: "q",
},
defaults: {
c: "maintain_ratio",
fo: "auto",
},
kvSeparator: "-",
paramSeparator: ",",
});
const generate = (src, operations) => {
const modifiers = operationsGenerator(operations);
const url = (0, utils_js_1.toUrl)(src);
url.searchParams.set("tr", modifiers);
return (0, utils_js_1.toCanonicalUrlString)(url);
};
exports.generate = generate;
const extract = (url) => {
const parsedUrl = (0, utils_js_1.toUrl)(url);
let trPart = null;
let path = parsedUrl.pathname;
// Check for query parameter format
if (parsedUrl.searchParams.has("tr")) {
trPart = parsedUrl.searchParams.get("tr");
parsedUrl.searchParams.delete("tr");
}
else {
// Check for path-based format
const pathParts = parsedUrl.pathname.split("/");
const trIndex = pathParts.findIndex((part) => part.startsWith("tr:"));
if (trIndex !== -1) {
trPart = pathParts[trIndex].slice(3); // Remove 'tr:' prefix
path = pathParts.slice(0, trIndex).concat(pathParts.slice(trIndex + 1)).join("/");
}
}
if (!trPart) {
return null;
}
parsedUrl.pathname = path;
const operations = operationsParser(trPart);
return {
src: (0, utils_js_1.toCanonicalUrlString)(parsedUrl),
operations,
};
};
exports.extract = extract;
exports.transform = (0, utils_js_1.createExtractAndGenerate)(exports.extract, exports.generate);