calamity-0.7.0.0: Calamity/Utils/CDNUrl.hs
-- | CDN url stuff
module Calamity.Utils.CDNUrl (
cdnURL,
assetHashFile,
isGIFAsset,
) where
import qualified Data.Text as T
import qualified Network.HTTP.Req as Req
-- | The CDN URL
cdnURL :: Req.Url 'Req.Https
cdnURL = Req.https "cdn.discordapp.com"
-- | Test if an asset hash is animated
isGIFAsset :: T.Text -> Bool
isGIFAsset = T.isPrefixOf "a_"
-- | Generate \'hash.ext\' for an asset hash. @ext@ will be \'gif\' for animated
-- assets, \'png\' otherwise.
assetHashFile :: T.Text -> T.Text
assetHashFile h = if isGIFAsset h then h <> ".gif" else h <> ".png"