aboutsummaryrefslogtreecommitdiff
path: root/server/lib/Uplcg/BaseUrl.hs
blob: f49d0d08ce89b354e9d23e4f30cd6dd63e863703 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 (== '/')