Skip to content

Commit

Permalink
🐛 修复图片文件使用相对路径检查是否存在不准确的问题
Browse files Browse the repository at this point in the history
Signed-off-by: liutianqi <[email protected]>
  • Loading branch information
iTanken committed Jan 26, 2024
1 parent ece2f19 commit 8a28ce3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ func decodeBase64(src, parent string) (string, error) {
if !filepath.IsAbs(path) {
path = filepath.Join(parent, path)
}
if fi, err := os.Stat(path); os.IsNotExist(err) || fi.IsDir() {
// no image file found
return path, err
}
f, err := os.Open(path)
if err != nil {
var pathErr *os.PathError
Expand Down Expand Up @@ -414,10 +418,6 @@ func embedImage(src, parent string) (string, error) {
color.Yellow("🙈 Embed Image Ignore [%d] %s", i+1, imgSrc)
continue
}
if f, e := os.Stat(imgSrc); os.IsNotExist(e) || f.IsDir() {
// no image file found
continue
}

b64img, err := decodeBase64(imgSrc, parent)
if err != nil {
Expand Down

0 comments on commit 8a28ce3

Please sign in to comment.