repochecker: Markdown: unescape path to images
This commit is contained in:
parent
55f7d0826e
commit
636cc2b55b
@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/base32"
|
||||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@ -79,6 +80,12 @@ func (t *imageImporterTransformer) Transform(doc *ast.Document, reader text.Read
|
||||
switch child := node.(type) {
|
||||
case *ast.Image:
|
||||
iPath := string(child.Destination)
|
||||
|
||||
// Unescape string if needed (mostly %20 to space)
|
||||
if ip, err := url.QueryUnescape(iPath); err == nil {
|
||||
iPath = ip
|
||||
}
|
||||
|
||||
dPath := path.Join(fic.FilesDir, strings.ToLower(base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(t.hash[:])), iPath)
|
||||
child.Destination = []byte(path.Join(t.absPath, string(child.Destination)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user