on master help sign in
Improved UA presentation
commit110d3945d79010a43cc2e283cd1f7f64d38d5103 authoriko <ilyakooo0@gmail.com> dateSat 11 May 2019, 12:45 (7 years ago) parent1a318fa
1 file changed+6−6
denis/src/Server/Auth.hs+6−6
denis/src/Server/Auth.hs+6−6
@@ -225,13 +225,13 @@ getUserAgent uaData' = fromMaybe "Unknown" $ do
225225 uaData <- fmap C.pack uaData'
226226 let os = osrFamily <$> parseOS uaData
227227 let browser = uarFamily <$> parseUA uaData
228− foldl mappendMaybe Nothing $ [os, browser]
228+ foldl (mappendMaybeThrough " — ") Nothing $ [os, browser]
229229 where
230− mappendMaybe :: (Semigroup a) => Maybe a -> Maybe a -> Maybe a
231− mappendMaybe Nothing (Just a) = Just a
232− mappendMaybe (Just a) Nothing = Just a
233− mappendMaybe (Just a) (Just b) = Just (a <> b)
234− mappendMaybe Nothing Nothing = Nothing
230+ mappendMaybeThrough :: (Semigroup a) => a -> Maybe a -> Maybe a -> Maybe a
231+ mappendMaybeThrough _ Nothing (Just a) = Just a
232+ mappendMaybeThrough _ (Just a) Nothing = Just a
233+ mappendMaybeThrough i (Just a) (Just b) = Just (a <> i <> b)
234+ mappendMaybeThrough _ Nothing Nothing = Nothing
235235
236236normalizaUser :: UserCreation -> UserCreation
237237normalizaUser (UserCreation fName mName lName faculty email) =