From 67a7a8c35846b26fb51f7413f1bf1fc9b01c1962 Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Mon, 19 Mar 2018 14:08:12 -0700 Subject: [PATCH] Strip both single and double quotes --- src/Data/Abstract/Path.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Data/Abstract/Path.hs b/src/Data/Abstract/Path.hs index ce29e69bd..491507b57 100644 --- a/src/Data/Abstract/Path.hs +++ b/src/Data/Abstract/Path.hs @@ -3,7 +3,6 @@ module Data.Abstract.Path where import Prologue import qualified Data.ByteString.Char8 as BC import qualified Data.ByteString as B -import Data.Char (ord) -- | Split a 'ByteString' path on `/`, stripping quotes and any `./` prefix. splitOnPathSeparator :: ByteString -> [ByteString] @@ -13,7 +12,7 @@ splitOnPathSeparator' :: (ByteString -> ByteString) -> ByteString -> [ByteString splitOnPathSeparator' f = BC.split '/' . f . dropRelativePrefix . stripQuotes stripQuotes :: ByteString -> ByteString -stripQuotes = B.filter (/= fromIntegral (ord '\"')) +stripQuotes = B.filter (`B.notElem` "\'\"") dropRelativePrefix :: ByteString -> ByteString dropRelativePrefix = BC.dropWhile (== '/') . BC.dropWhile (== '.')