@@ -23,7 +23,9 @@ main = do
2323 pkgDirName p =
2424 if countDashes p < 2
2525 then error $ p ++ " not in name-version-hash format"
26− else (removeDashSegment . removeDashSegment) p
26+ else let nv_ = dropEnd 22 p in
27+ if last nv_ == '-' then removeDashSegment $ init nv_
28+ else error $ p ++ " not in name-version-hash format"
2729
2830 countDashes = length . filter (== '-')
2931
@@ -47,3 +49,9 @@ main = do
4749 return $ map fst $ sortBy compareSnd fileTimes
4850
4951 compareSnd (_,t1) (_,t2) = compare t1 t2
52+
53+-- from Data.List.Extra
54+dropEnd :: Int -> [a] -> [a]
55+dropEnd i xs = f xs (drop i xs)
56+ where f (x:xs) (y:ys) = x : f xs ys
57+ f _ _ = []