add dropFromEnd
This commit is contained in:
parent
acb4bcf2db
commit
850d19d038
5 changed files with 10 additions and 6 deletions
|
@ -30,6 +30,7 @@ import Utility.Data
|
|||
import Utility.PartialPrelude
|
||||
import Utility.Misc
|
||||
import Utility.Tuple
|
||||
import Utility.Split
|
||||
|
||||
import Data.List
|
||||
import Data.Time.Clock
|
||||
|
@ -265,7 +266,7 @@ toRecurrance s = case words s of
|
|||
constructor "month" = Just Monthly
|
||||
constructor "year" = Just Yearly
|
||||
constructor u
|
||||
| "s" `isSuffixOf` u = constructor $ reverse $ drop 1 $ reverse u
|
||||
| "s" `isSuffixOf` u = constructor $ dropFromEnd 1 u
|
||||
| otherwise = Nothing
|
||||
withday sd u = do
|
||||
c <- constructor u
|
||||
|
|
|
@ -28,3 +28,7 @@ splitc c s = case break (== c) s of
|
|||
-- | same as Data.List.Utils.replace
|
||||
replace :: Eq a => [a] -> [a] -> [a] -> [a]
|
||||
replace old new = intercalate new . split old
|
||||
|
||||
-- | Only traverses the list once while dropping the last n characters.
|
||||
dropFromEnd :: Int -> [a] -> [a]
|
||||
dropFromEnd n l = zipWith const l (drop n l)
|
||||
|
|
|
@ -278,8 +278,7 @@ getUrlInfo url uo = case parseURIRelaxed url of
|
|||
contentDispositionFilename :: String -> Maybe FilePath
|
||||
contentDispositionFilename s
|
||||
| "attachment; filename=\"" `isPrefixOf` s && "\"" `isSuffixOf` s =
|
||||
Just $ reverse $ drop 1 $ reverse $
|
||||
drop 1 $ dropWhile (/= '"') s
|
||||
Just $ dropFromEnd 1 $ drop 1 $ dropWhile (/= '"') s
|
||||
| otherwise = Nothing
|
||||
|
||||
headRequest :: Request -> Request
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue