@@ -17,8 +17,8 @@ import Control.Alt ((<|>))
17
17
import Control.Bind ((=<<))
18
18
import Data.Either (Either (..), either )
19
19
import Data.Maybe (Maybe (..))
20
- import Data.Path.Pathy (parseAbsDir , parseRelDir , parseAbsFile , parseRelFile , sandbox , rootDir , (</>), unsafePrintPath )
21
- import Data.String ( drop , length )
20
+ import Data.Path.Pathy (Path (), parseAbsDir , parseRelDir , parseAbsFile , parseRelFile , sandbox , rootDir , (</>), unsafePrintPath )
21
+ import Data.String as Str
22
22
import Data.URI.Common
23
23
import Data.URI.Types
24
24
import Text.Parsing.StringParser (Parser (..), ParseError (..), try )
@@ -67,19 +67,24 @@ parseSegmentNonZeroNoColon = joinWith "" <$> many1 (parseUnreserved
67
67
68
68
parseURIPathAbs :: Parser URIPathAbs
69
69
parseURIPathAbs = Parser \{ str: str, pos: i } fc sc ->
70
- case sandbox rootDir =<< parseAbsFile (drop i str) of
71
- Just file -> sc (Left $ rootDir </> file) { str: str, pos: length str }
72
- Nothing -> case sandbox rootDir =<< parseAbsDir (drop i str) of
73
- Just dir -> sc (Right $ rootDir </> dir) { str: str, pos: length str }
70
+ case sandbox rootDir =<< parseAbsFile (Str . drop i str) of
71
+ Just file -> sc (Left $ rootDir </> file) { str: str, pos: Str . length str }
72
+ Nothing -> case sandbox rootDir =<< parseAbsDir (Str . drop i str) of
73
+ Just dir -> sc (Right $ rootDir </> dir) { str: str, pos: Str . length str }
74
74
Nothing -> fc i (ParseError $ " Expected a valid path" )
75
75
76
76
parseURIPathRel :: Parser URIPathRel
77
77
parseURIPathRel = Parser \{ str: str, pos: i } fc sc ->
78
- case parseRelFile (drop i str) of
79
- Just file -> sc (Left file) { str: str, pos: length str }
80
- Nothing -> case parseRelDir (drop i str) of
81
- Just dir -> sc (Right dir) { str: str, pos: length str }
78
+ case parseRelFile (Str . drop i str) of
79
+ Just file -> sc (Left file) { str: str, pos: Str . length str }
80
+ Nothing -> case parseRelDir (Str . drop i str) of
81
+ Just dir -> sc (Right dir) { str: str, pos: Str . length str }
82
82
Nothing -> fc i (ParseError $ " Expected a valid path" )
83
83
84
84
printPath :: forall a s . URIPath a s -> String
85
- printPath = either unsafePrintPath unsafePrintPath
85
+ printPath = either print print
86
+ where
87
+ print :: forall a' b s' . Path a' b s' -> String
88
+ print path =
89
+ let printed = unsafePrintPath path
90
+ in if Str .take 2 printed == " ./" then Str .drop 2 printed else printed
0 commit comments