diff options
author | John MacFarlane <jgm@berkeley.edu> | 2021-05-29 14:41:28 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2021-05-29 14:41:28 -0700 |
commit | 0d7103de7e893002eedcc50fea7f81aae9535106 (patch) | |
tree | 5deefdaea2c23ca568afc3a573fa3d10871ea069 | |
parent | c210b983662c26c0b827c9199f6f1a2b34c1559e (diff) | |
download | pandoc-0d7103de7e893002eedcc50fea7f81aae9535106.tar.gz |
In rebasePath, check for absolute paths two ways.
isAbsolute from FilePath doesn't return True on Windows
for paths beginning with `/`, so we check that separately.
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index bc5e3e30f..9a5e0889e 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1924,7 +1924,10 @@ rebasePath :: SourcePos -> Text -> Text rebasePath pos path = do let fp = sourceName pos isFragment = T.take 1 path == "#" - in if T.null path || isFragment || isAbsolute (T.unpack path) || isURI path + -- check for leading / because on Windows this won't be + -- recognized as absolute by isAbsolute + isAbsolutePath = isAbsolute (T.unpack path) || T.take 1 path == "/" + in if T.null path || isFragment || isAbsolutePath || isURI path then path else case takeDirectory fp of |