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

Function decodeNotebookIdFromFilename

packages/convert/src/snapshot/split.ts:73–87  ·  view source on GitHub ↗
(encoded: string)

Source from the content-addressed store, hash-verified

71
72/** Recovers the original notebook id from a component produced by {@link encodeNotebookIdForFilename}. */
73export 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.

Callers 2

split.test.tsFile · 0.90
parseSnapshotFilenameFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected