fix(01-review): WR-07 base64ToBlob empty-input shortcut + SW-side empty-segment filter
This commit is contained in:
@@ -65,6 +65,17 @@ export async function blobToBase64(blob: Blob): Promise<string> {
|
||||
* @returns A Blob whose bytes match the original encoded blob exactly.
|
||||
*/
|
||||
export function base64ToBlob(b64: string, mimeType: string): Blob {
|
||||
// WR-07 fix: defensive early-return for empty input. `atob('')` returns
|
||||
// an empty string and the resulting Blob has size 0 — currently no
|
||||
// caller filters zero-size segments, which would corrupt the
|
||||
// concatenated WebM with a stray empty EBML segment. Return an
|
||||
// explicit empty Blob here so the SW-side filter on
|
||||
// `segment.data.size > 0` (see src/background/index.ts
|
||||
// getVideoBufferFromOffscreen) can pre-filter cleanly without an
|
||||
// extra atob round-trip.
|
||||
if (b64.length === 0) {
|
||||
return new Blob([], { type: mimeType });
|
||||
}
|
||||
const binary = atob(b64);
|
||||
const bytes = new Uint8Array(binary.length);
|
||||
for (let i = 0; i < binary.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user