diff --git a/src/Main.hs b/src/Main.hs index 17ade3f..916a3e5 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -71,12 +71,15 @@ normalizeDirectory :: String -> String normalizeDirectory s = if "/" `isSuffixOf` s then s else s ++ "/" userLicenseDir :: IO String -userLicenseDir = xdgConfigHome <&> (++ defaultUserLicenseDirName) +userLicenseDir = + xdgConfigHome <&> (normalizeDirectory . (++ defaultUserLicenseDirName)) where xdgConfigHome :: IO String - xdgConfigHome = - (lookupEnv "XDG_CONFIG_HOME") - >>= maybe userHomeDir (return . normalizeDirectory) + xdgConfigHome = do + xch <- lookupEnv "XDG_CONFIG_HOME" + case xch of + Just p@(_ : _) -> return $ normalizeDirectory p + _ -> userHomeDir <&> (++ ".config/") userHomeDir :: IO String userHomeDir = getEnv "HOME" <&> normalizeDirectory