diff --git a/pkg.go b/pkg.go index e4c1c22..2014bf2 100644 --- a/pkg.go +++ b/pkg.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "path/filepath" "time" + "strings" ) const ( @@ -146,6 +147,7 @@ func newPackage() *pkg { } func (p *pkg) addToManifest(id string, href string, mediaType string, properties string) { + href = strings.Replace(href, "\\", "/", -1) i := &pkgItem{ ID: id, Href: href, diff --git a/toc.go b/toc.go index bab654f..1663291 100644 --- a/toc.go +++ b/toc.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "path/filepath" "strconv" + "strings" ) const ( @@ -148,6 +149,7 @@ func newTocNcxXML() *tocNcxRoot { // Add a section to the TOC (navXML as well as ncxXML) func (t *toc) addSection(index int, title string, relativePath string) { + relativePath = strings.Replace(relativePath, "\\", "/", -1) l := &tocNavItem{ A: tocNavLink{ Href: relativePath, diff --git a/write.go b/write.go index 5212c54..d238f18 100644 --- a/write.go +++ b/write.go @@ -220,6 +220,7 @@ func (e *Epub) writeEpub(tempDir string, destFilePath string) error { // Get the path of the file relative to the folder we're zipping relativePath, err := filepath.Rel(tempDir, path) + relativePath = strings.Replace(relativePath, "\\", "/", -1) if err != nil { // tempDir and path are both internal, so we shouldn't get here panic(fmt.Sprintf("Error closing EPUB file: %s", err))