fix: better handling of epub path with anchor on windows

Closes: #1909
This commit is contained in:
Gauthier Roebroeck 2025-03-11 13:35:22 +08:00
parent 48e6eaf41d
commit cd6b83d14d

View file

@ -21,7 +21,12 @@ fun Document.getManifest() =
fun normalizeHref(
opfDir: Path?,
href: String,
) = (opfDir?.resolve(href)?.normalize() ?: Paths.get(href)).invariantSeparatorsPathString
): String {
val anchor = href.substringAfterLast("#", "")
val base = href.substringBeforeLast("#")
val resolvedPath = (opfDir?.resolve(base)?.normalize() ?: Paths.get(base)).invariantSeparatorsPathString
return resolvedPath + if (anchor.isNotBlank()) "#$anchor" else ""
}
/**
* Process an OPF document and extracts TOC entries