MCPcopy Create free account
hub / github.com/ScattrdBlade/bigFileUpload / parseShareXConfig

Function parseShareXConfig

utils/sharex.ts:37–62  ·  view source on GitHub ↗
(configText: string)

Source from the content-addressed store, hash-verified

35}
36
37export function parseShareXConfig(configText: string): ShareXUploaderConfig {
38 let parsed: unknown;
39 const normalizedConfigText = configText.replace(/^\uFEFF/, "").trim();
40
41 try {
42 parsed = JSON.parse(normalizedConfigText);
43 } catch {
44 throw new Error("Invalid ShareX JSON");
45 }
46
47 if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
48 throw new Error("ShareX config must be a JSON object");
49 }
50
51 const config = parsed as ShareXUploaderConfig;
52
53 if (!config.RequestURL || typeof config.RequestURL !== "string") {
54 throw new Error("ShareX RequestURL is required");
55 }
56
57 if (!isSupportedShareXDestination(config)) {
58 throw new Error("ShareX DestinationType must include FileUploader or ImageUploader");
59 }
60
61 return config;
62}
63
64export function isSupportedShareXDestination(config: ShareXUploaderConfig): boolean {
65 const destinationTypes = parseDestinationTypes(config.DestinationType);

Callers 3

validateShareXConfigFunction · 0.90
handleShareXFileUploadFunction · 0.90

Calls 1

Tested by

no test coverage detected