Skip to content

Commit 7ca1731

Browse files
committed
Use page ID by default instead of path
1 parent 1678131 commit 7ca1731

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

src/processors/obfProcessor.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,19 +227,11 @@ class ObfProcessor extends BaseProcessor {
227227
}
228228
}
229229

230-
private async processBoard(
231-
boardData: ObfBoard,
232-
_boardPath: string,
233-
isZipEntry: boolean
234-
): Promise<AACPage> {
230+
private async processBoard(boardData: ObfBoard, _boardPath: string): Promise<AACPage> {
235231
const sourceButtons = boardData.buttons || [];
236232

237233
// Calculate page ID first (used to make button IDs unique)
238-
const pageId = isZipEntry
239-
? _boardPath // Zip entry - use filename to match navigation paths
240-
: boardData?.id
241-
? String(boardData.id)
242-
: _boardPath?.split(/[/\\]/).pop() || '';
234+
const pageId = boardData?.id ? String(boardData.id) : _boardPath?.split(/[/\\]/).pop() || '';
243235

244236
const images = boardData.images;
245237

@@ -471,7 +463,7 @@ class ObfProcessor extends BaseProcessor {
471463
const boardData = await tryParseObfJson(content);
472464
if (boardData) {
473465
console.log('[OBF] Detected .obf file, parsed as JSON');
474-
const page = await this.processBoard(boardData, filePathOrBuffer, false);
466+
const page = await this.processBoard(boardData, filePathOrBuffer);
475467
tree.addPage(page);
476468

477469
// Set metadata from root board
@@ -513,7 +505,7 @@ class ObfProcessor extends BaseProcessor {
513505
const asJson = await tryParseObfJson(filePathOrBuffer);
514506
if (!asJson) throw new Error('Invalid OBF content: not JSON and not ZIP');
515507
console.log('[OBF] Detected buffer/string as OBF JSON');
516-
const page = await this.processBoard(asJson, '[bufferOrString]', false);
508+
const page = await this.processBoard(asJson, '[bufferOrString]');
517509
tree.addPage(page);
518510

519511
// Set metadata from root board
@@ -593,7 +585,7 @@ class ObfProcessor extends BaseProcessor {
593585
const content = await this.zipFile.readFile(entryName);
594586
const boardData = await tryParseObfJson(decodeText(content));
595587
if (boardData) {
596-
const page = await this.processBoard(boardData, entryName, true);
588+
const page = await this.processBoard(boardData, entryName);
597589
tree.addPage(page);
598590

599591
// Set metadata if not already set (use first board as reference)

0 commit comments

Comments
 (0)