Spaces:
Sleeping
Sleeping
Download client/src/blocks/utils.ts from incognitolm/RealBlocks: direct link, hf CLI and curl.
- Browser
- Download file 707 Bytes
-
https://huggingface.co/spaces/incognitolm/RealBlocks/resolve/main/client/src/blocks/utils.ts
- Command line
-
hf download hf://spaces/incognitolm/RealBlocks/client/src/blocks/utils.ts
-
curl -L -o utils.ts https://huggingface.co/spaces/incognitolm/RealBlocks/resolve/main/client/src/blocks/utils.ts
707 Bytes
| // Names typed by users (functions, variables, params) may contain spaces and | |
| // special characters. When a name is emitted into generated code it is | |
| // URL-encoded, then each `%` is escaped as `\u0025` so the percent sign is | |
| // representable in the output text. E.g. "my variable" -> "my\u002520variable". | |
| export function encodeName(name: string): string { | |
| return encodeURIComponent(String(name ?? '')).replace(/%/g, '\\u0025'); | |
| } | |
| // Encode a comma-separated list of names (used for legacy param fields). | |
| export function encodeNameList(list: string): string { | |
| return String(list ?? '') | |
| .split(',') | |
| .map((p) => p.trim()) | |
| .filter((p) => p.length > 0) | |
| .map(encodeName) | |
| .join(', '); | |
| } | |