allow pathdepth to drop from the front or take from the end (negative)
This commit is contained in:
parent
c2245260b1
commit
346c934409
2 changed files with 7 additions and 7 deletions
|
@ -90,13 +90,12 @@ url2file :: URI -> Maybe Int -> FilePath
|
|||
url2file url pathdepth = case pathdepth of
|
||||
Nothing -> filesize $ escape fullurl
|
||||
Just depth
|
||||
| depth > 0 -> filesize $ join "/" $
|
||||
fromend depth $ map escape $
|
||||
filter (not . null) $ split "/" fullurl
|
||||
| otherwise -> error "bad --pathdepth value"
|
||||
| depth > 0 -> frombits $ drop depth
|
||||
| otherwise -> frombits $ reverse . take (negate depth) . reverse
|
||||
where
|
||||
fullurl = uriRegName auth ++ uriPath url ++ uriQuery url
|
||||
frombits a = filesize $ join "/" $ a urlbits
|
||||
urlbits = map escape $ filter (not . null) $ split "/" fullurl
|
||||
auth = fromMaybe (error $ "bad url " ++ show url) $ uriAuthority url
|
||||
filesize = take 255
|
||||
escape = replace "/" "_" . replace "?" "_"
|
||||
fromend n = reverse . take n . reverse
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue