Skip to content

Commit d80c2da

Browse files
authored
Fix: Error opening an OPDS Catalog
1 parent 160dc89 commit d80c2da

5 files changed

Lines changed: 16 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1010

1111
- Error opening files from the system file explorer [`cecc15d`](https://github.com/ollm/OpenComic/commit/cecc15d44c15545fddb932ee87d99213015f295e)
1212
- Invert tap zones in manga reading [`08a4d10`](https://github.com/ollm/OpenComic/commit/08a4d10115b4687631bd23695d2accff7933ba81)
13+
- Error opening an OPDS Catalog
1314

1415
## [v1.5.0](https://github.com/ollm/OpenComic/releases/tag/v1.5.0) (19-06-2025)
1516

scripts/dom/labels.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async function _opds(url = false, index = false, title = false)
4040
const base64 = opds.opds.base64(url);
4141
opds.addPathName(base64, title);
4242

43-
const path = 'opds:/'+base64;
43+
const path = 'opds:'+p.sep+base64;
4444
await dom.loadIndexPage(true, path, false, false, path);
4545
}
4646
}

scripts/opds.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,12 @@ async function boxes(path = false, mainPath = false)
835835

836836
for(const key in opdsCatalogs)
837837
{
838-
files.push(...Object.values(opdsCatalogs[key].downloadFiles));
838+
files.push(...Object.values(opdsCatalogs[key].downloadFiles ?? {}));
839839
}
840840
}
841841
else
842842
{
843-
files.push(...Object.values(currentCatalog.downloadFiles));
843+
files.push(...Object.values(currentCatalog.downloadFiles ?? {}));
844844
}
845845

846846
const comics = [];

scripts/opds/opds.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function convertPublicationsToFile(feed, path, mainPath, currentUrl)
243243
const _base64 = base64(resolveUrl(currentUrl, self.href));
244244

245245
group.mainPath = mainPath;
246-
group.path = p.join(path, _base64);
246+
group.path = serverClient.fixStart(p.join(path, _base64));
247247

248248
opds.addPathName(_base64, group.metadata.title);
249249
}
@@ -409,7 +409,7 @@ function parseUrls(feed, path, mainPath, currentUrl)
409409
const navigation = feed.navigation[i];
410410
const _base64 = base64(resolveUrl(currentUrl, navigation.href));
411411

412-
navigation.path = p.join(path, _base64);
412+
navigation.path = serverClient.fixStart(p.join(path, _base64));
413413
navigation.mainPath = mainPath;
414414
navigation.differentHost = differentHost(currentUrl, navigation.href) ? navigation.href : false;
415415

@@ -427,7 +427,7 @@ function parseUrls(feed, path, mainPath, currentUrl)
427427
{
428428
const _base64 = base64(resolveUrl(currentUrl, pagination.href));
429429

430-
pagination.path = p.join(p.dirname(path), _base64);
430+
pagination.path = serverClient.fixStart(p.join(p.dirname(path), _base64));
431431
pagination.mainPath = mainPath;
432432

433433
opds.addPathName(_base64, opds.pathName(p.basename(path)));
@@ -449,7 +449,7 @@ function parseUrls(feed, path, mainPath, currentUrl)
449449
const rel = getRel(link.rel);
450450
const _base64 = base64(resolveUrl(currentUrl, link.href));
451451

452-
link.path = p.join(p.dirname(path), _base64);
452+
link.path = serverClient.fixStart(p.join(p.dirname(path), _base64));
453453
link.mainPath = mainPath;
454454
link.active = rel == 'self' ? true : false;
455455

@@ -521,7 +521,7 @@ function getPath(item, currentUrl, mainPath)
521521
if(isOpdsCatalog(link.type))
522522
{
523523
const _base64 = base64(resolveUrl(currentUrl, link.href));
524-
link.path = p.join(mainPath, _base64);
524+
link.path = serverClient.fixStart(p.join(mainPath, _base64));
525525

526526
opds.addPathName(_base64, (link.title || link.name || item.title || item.name || opds.pathName(p.basename(mainPath))));
527527

scripts/server-client.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ function fixPath(path)
7878
return path.replace(/^(?:\.[\/\\]+)?([a-z0-9]+)\:[\/\\]{1,2}/, '$1:'+p.sep+p.sep);
7979
}
8080

81+
// Windows only
82+
function fixStart(path)
83+
{
84+
return path.replace(/^(?:\.[\/\\]+)/, '');
85+
}
86+
8187
function isDomain(host)
8288
{
8389
return /\./.test(host) ? true : false;
@@ -1770,6 +1776,7 @@ module.exports = {
17701776
getAdress: getAdress,
17711777
getTypeAdress: getTypeAdress,
17721778
fixPath: fixPath,
1779+
fixStart: fixStart,
17731780
posixPath: posixPath,
17741781
servers: function(){return servers},
17751782
serverLastError: _serverLastError,

0 commit comments

Comments
 (0)