From 1eae95ea5dcfc692833bfbacaa6550e269cbe184 Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Mon, 23 Jul 2018 14:38:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9Markdown=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E7=9A=84=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/BookModel.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/models/BookModel.go b/models/BookModel.go index 2df35b4f..a22eb33a 100644 --- a/models/BookModel.go +++ b/models/BookModel.go @@ -715,12 +715,18 @@ func (book *Book) ImportBook(zipPath string) error { originalLink := links[0][2] var linkPath string var err error + if strings.HasPrefix(originalLink,"<") { + originalLink = strings.TrimPrefix(originalLink,"<") + } + if strings.HasSuffix(originalLink,">") { + originalLink = strings.TrimSuffix(originalLink,">") + } //如果是从根目录开始, - if strings.HasPrefix(originalLink,"/") { - linkPath,err = filepath.Abs(filepath.Join(tempPath,originalLink)) - }else if strings.HasPrefix(originalLink, "./"){ + if strings.HasPrefix(originalLink, "/") { + linkPath, err = filepath.Abs(filepath.Join(tempPath, originalLink)) + } else if strings.HasPrefix(originalLink, "./") { linkPath, err = filepath.Abs(filepath.Join(filepath.Dir(path), originalLink[1:])) - }else{ + } else{ linkPath, err = filepath.Abs(filepath.Join(filepath.Dir(path), originalLink)) }