1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 00:33:59 +03:00

Strip both single and double quotes

This commit is contained in:
Timothy Clem 2018-03-19 14:08:12 -07:00
parent 811370a767
commit 67a7a8c358

View File

@ -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 (== '.')