(encoded: string)
| 71 | |
| 72 | /** Recovers the original notebook id from a component produced by {@link encodeNotebookIdForFilename}. */ |
| 73 | export function decodeNotebookIdFromFilename(encoded: string): string { |
| 74 | const bytes: number[] = [] |
| 75 | let i = 0 |
| 76 | while (i < encoded.length) { |
| 77 | const hex = encoded.slice(i + 1, i + 3) |
| 78 | if (encoded[i] === '%' && /^[0-9A-Fa-f]{2}$/.test(hex)) { |
| 79 | bytes.push(Number.parseInt(hex, 16)) |
| 80 | i += 3 |
| 81 | } else { |
| 82 | bytes.push(encoded.charCodeAt(i)) |
| 83 | i += 1 |
| 84 | } |
| 85 | } |
| 86 | return utf8Decoder.decode(new Uint8Array(bytes)) |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Generates a snapshot filename from project info. |
no outgoing calls
no test coverage detected