@hauptsache.net/clickup-mcp
Version:
Search, create, and retrieve tasks, add comments, and track time through natural language commands.
35 lines (34 loc) • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseDataUri = parseDataUri;
exports.estimateBase64Size = estimateBase64Size;
/**
* Parse data URI strings of the form data:mime/type;base64,....
* Returns null if the value is not a base64 data URI.
*/
function parseDataUri(dataUri) {
if (!dataUri.startsWith("data:")) {
return null;
}
const match = dataUri.match(/^data:([^;]+);base64,(.+)$/s);
if (!match) {
return null;
}
const [, mimeType, base64Part] = match;
const sanitizedBase64 = base64Part.replace(/\s+/g, "");
if (!sanitizedBase64) {
return null;
}
return {
mimeType,
base64Data: sanitizedBase64,
};
}
/**
* Estimate the decoded byte-size of base64 data without allocating buffers
*/
function estimateBase64Size(base64Data) {
const sanitized = base64Data.replace(/\s+/g, "");
const padding = sanitized.endsWith("==") ? 2 : sanitized.endsWith("=") ? 1 : 0;
return Math.max(0, (sanitized.length * 3) / 4 - padding);
}