diff options
Diffstat (limited to 'server/lib/Uplcg/BaseUrl.hs')
-rw-r--r-- | server/lib/Uplcg/BaseUrl.hs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/server/lib/Uplcg/BaseUrl.hs b/server/lib/Uplcg/BaseUrl.hs new file mode 100644 index 0000000..f49d0d0 --- /dev/null +++ b/server/lib/Uplcg/BaseUrl.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE OverloadedStrings #-} +module Uplcg.BaseUrl + ( BaseUrl (..) + , parse + , render + ) where + +import qualified Data.Text as T + +newtype BaseUrl = BaseUrl [T.Text] deriving (Show) + +render :: BaseUrl -> T.Text +render (BaseUrl []) = "" +render (BaseUrl xs) = "/" <> T.intercalate "/" xs + +parse :: T.Text -> BaseUrl +parse = BaseUrl . filter (not . T.null) . T.split (== '/') |