generated from ztimson/template
Better pathing
This commit is contained in:
@@ -73,8 +73,10 @@ export class ZimManager {
|
||||
/** Resolves a file path or catalog `name` to a local file path. */
|
||||
async #resolveFile(fileOrName) {
|
||||
if (fs.existsSync(fileOrName)) return fileOrName;
|
||||
const joined = path.join(this.#dir, fileOrName);
|
||||
if (fs.existsSync(joined)) return joined;
|
||||
const local = await this.list();
|
||||
const match = local.find(l => l.meta?.name === fileOrName);
|
||||
const match = local.find(l => l.meta?.name === fileOrName || path.basename(l.file) === fileOrName);
|
||||
if (!match) throw new Error(`ZIM not found locally: ${fileOrName}`);
|
||||
return match.file;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user