| Server IP : 159.203.156.69 / Your IP : 216.73.216.37 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 detect_js_1 = require("../detect.js");
const utils_js_1 = require("../utils.js");
const { operationsGenerator, operationsParser } = (0, utils_js_1.createOperationsHandlers)({
keyMap: {
format: "force_format",
width: "w",
height: "h",
quality: "q",
},
defaults: {
org_if_sml: 1,
},
});
const generate = (src, modifiers = {}, { token } = {}) => {
if (!token) {
throw new Error("Token is required for Cloudimage URLs" + src);
}
let srcString = src.toString();
srcString = srcString.replace(/^https?:\/\//, "");
if (srcString.includes("?")) {
modifiers.ci_url_encoded = 1;
srcString = encodeURIComponent(srcString);
}
const operations = operationsGenerator(modifiers);
const url = new URL(`https://${token}.cloudimg.io/`);
url.pathname = srcString;
url.search = operations;
return url.toString();
};
exports.generate = generate;
const extract = (src, options = {}) => {
const url = (0, utils_js_1.toUrl)(src);
if ((0, detect_js_1.getProviderForUrl)(url) !== "cloudimage") {
return null;
}
const operations = operationsParser(url);
let originalSrc = url.pathname;
if (operations.ci_url_encoded) {
originalSrc = decodeURIComponent(originalSrc);
delete operations.ci_url_encoded;
}
options.token ??= url.hostname.replace(".cloudimg.io", "");
return {
src: `${url.protocol}/${originalSrc}`,
operations,
options,
};
};
exports.extract = extract;
exports.transform = (0, utils_js_1.createExtractAndGenerate)(exports.extract, exports.generate);