MCPcopy Index your code
hub / github.com/deepnote/deepnote / encodeNotebookIdForFilename

Function encodeNotebookIdForFilename

packages/convert/src/snapshot/split.ts:58–70  ·  view source on GitHub ↗
(notebookId: string)

Source from the content-addressed store, hash-verified

56 * become uppercase `%XX` UTF-8 escapes. Lossless one-to-one mapping; inverse: {@link decodeNotebookIdFromFilename}.
57 */
58export 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}. */
73export function decodeNotebookIdFromFilename(encoded: string): string {

Callers 2

split.test.tsFile · 0.90
generateSnapshotFilenameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected