MCPcopy Create free account
hub / github.com/pollinations/pollinations / parseSafeFeatures

Function parseSafeFeatures

shared/schemas/safety.ts:48–64  ·  view source on GitHub ↗
(value: SafeValue)

Source from the content-addressed store, hash-verified

46}
47
48export function parseSafeFeatures(value: SafeValue): Set<SafetyFeature> {
49 const normalized = normalizeSafeValue(value);
50 if (!normalized) return new Set();
51
52 const features = new Set<SafetyFeature>();
53 for (const part of normalized.split(",")) {
54 const token = part.trim().toLowerCase();
55 if (!VALID_SAFE_TOKENS.has(token)) continue;
56 if (DISABLED_SAFE_TOKENS.has(token)) continue;
57 for (const feature of SAFETY_ALIASES[token] ?? [
58 token as SafetyFeature,
59 ]) {
60 features.add(feature);
61 }
62 }
63 return features;
64}
65
66export const SafeSchema = z
67 .union([z.string(), z.boolean()])

Callers 4

safety.test.tsFile · 0.90
hasActiveSafetyFunction · 0.90
hasActiveSafetyFunction · 0.90
getRequestFeaturesFunction · 0.90

Calls 2

normalizeSafeValueFunction · 0.85
addMethod · 0.80

Tested by

no test coverage detected