repochecker: Markdown: unescape path to images
This commit is contained in:
parent
55f7d0826e
commit
636cc2b55b
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base32"
|
"encoding/base32"
|
||||||
"io"
|
"io"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
@ -79,6 +80,12 @@ func (t *imageImporterTransformer) Transform(doc *ast.Document, reader text.Read
|
|||||||
switch child := node.(type) {
|
switch child := node.(type) {
|
||||||
case *ast.Image:
|
case *ast.Image:
|
||||||
iPath := string(child.Destination)
|
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)
|
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)))
|
child.Destination = []byte(path.Join(t.absPath, string(child.Destination)))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user