(value, transport)
| 36 | * @param {Transport} transport |
| 37 | */ |
| 38 | export function stringify_remote_arg(value, transport) { |
| 39 | if (value === undefined) return ''; |
| 40 | |
| 41 | // If people hit file/url size limits, we can look into using something like compress_and_encode_text from svelte.dev beyond a certain size |
| 42 | const json_string = stringify(value, transport); |
| 43 | |
| 44 | // Convert to UTF-8 bytes, then base64 - handles all Unicode properly (btoa would fail on exotic characters) |
| 45 | const utf8_bytes = new TextEncoder().encode(json_string); |
| 46 | return btoa(String.fromCharCode(...utf8_bytes)) |
| 47 | .replace(/=/g, '') |
| 48 | .replace(/\+/g, '-') |
| 49 | .replace(/\//g, '_'); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Parses the argument (if any) for a remote function |
no test coverage detected