(notebookId: string)
| 56 | * become uppercase `%XX` UTF-8 escapes. Lossless one-to-one mapping; inverse: {@link decodeNotebookIdFromFilename}. |
| 57 | */ |
| 58 | export function encodeNotebookIdForFilename(notebookId: string): string { |
| 59 | let encoded = '' |
| 60 | for (const char of notebookId) { |
| 61 | if (FILENAME_SAFE_NOTEBOOK_ID_CHAR.test(char)) { |
| 62 | encoded += char |
| 63 | continue |
| 64 | } |
| 65 | for (const byte of utf8Encoder.encode(char)) { |
| 66 | encoded += `%${byte.toString(16).toUpperCase().padStart(2, '0')}` |
| 67 | } |
| 68 | } |
| 69 | return encoded |
| 70 | } |
| 71 | |
| 72 | /** Recovers the original notebook id from a component produced by {@link encodeNotebookIdForFilename}. */ |
| 73 | export function decodeNotebookIdFromFilename(encoded: string): string { |
no outgoing calls
no test coverage detected