Fix stripDir p p /= Nothing bug
This commit is contained in:
parent
8f3b169760
commit
4e1816392a
@ -9,3 +9,6 @@
|
||||
0.4.0:
|
||||
* Implemented stricter parsing, disabling use of "..".
|
||||
* Made stripDir generic over MonadThrow
|
||||
|
||||
0.5.0:
|
||||
* Fix stripDir p p /= Nothing bug.
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: path
|
||||
version: 0.4.0
|
||||
version: 0.5.0
|
||||
synopsis: Path
|
||||
description: Path
|
||||
license: BSD3
|
||||
@ -10,6 +10,7 @@ copyright: 2015 FP Complete
|
||||
category: Filesystem
|
||||
build-type: Simple
|
||||
cabal-version: >=1.8
|
||||
extra-source-files: README.md, CHANGELOG
|
||||
|
||||
library
|
||||
hs-source-dirs: src/
|
||||
|
@ -244,9 +244,10 @@ toFilePath (Path l) = l
|
||||
stripDir :: MonadThrow m
|
||||
=> Path b Dir -> Path b t -> m (Path Rel t)
|
||||
stripDir (Path p) (Path l) =
|
||||
case fmap Path (stripPrefix p l) of
|
||||
case stripPrefix p l of
|
||||
Nothing -> throwM (Couldn'tStripPrefixDir p l)
|
||||
Just ok -> return ok
|
||||
Just "" -> throwM (Couldn'tStripPrefixDir p l)
|
||||
Just ok -> return (Path ok)
|
||||
|
||||
-- | Is p a parent of the given location? Implemented in terms of
|
||||
-- 'stripDir'. The bases must match.
|
||||
|
@ -101,6 +101,10 @@ operationStripDir =
|
||||
($(mkRelDir "bar/") </>
|
||||
$(mkRelFile "bob/foo.txt")) ==
|
||||
Just $(mkRelFile "bob/foo.txt"))
|
||||
it "stripDir parent parent = _|_"
|
||||
(stripDir $(mkAbsDir "/home/chris/foo")
|
||||
$(mkAbsDir "/home/chris/foo") ==
|
||||
Nothing)
|
||||
|
||||
-- | The '</>' operation.
|
||||
operationAppend :: Spec
|
||||
|
Loading…
Reference in New Issue
Block a user