Browse Source

URI: Relative path fetcher

Marcos Dumay de Medeiros 7 years ago
parent
commit
5d7ef7931d
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/Data/SMTP/Types/URI.hs

+ 9 - 0
src/Data/SMTP/Types/URI.hs

@@ -13,9 +13,18 @@ data Parameter = Parameter String String deriving (Eq, Ord, Read, Show)
 data URI = URI {account :: Account, path :: Path, revision :: Revision, parameters :: [Parameter]} 
          deriving (Eq, Ord)
 
+{- |
+Returns the entire path of the URI.
+-}
 fullPath :: URI -> String
 fullPath URI{path=Path p} = intercalate "/" $ map uriEncode p
 
+{- |
+Returns the entire path of the URI, except for the leading slash (/).
+-}
+relativePath :: URI -> String
+relativePath URI{path=Path p} = intercalate "/" . map uriEncode $ drop 1 p
+
 fullURI :: URI -> String
 fullURI u@(URI{account=a, revision=r, parameters=pp}) =
   concat $ ["FCMTP://", s . fullAccount $ a, fullPath u] ++ (