From 08c21993a7f773deb26be91c99f0e12ee3d5f54a Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 29 Oct 2017 22:46:39 +0300 Subject: Default to HTML on HTTP --- Pancake.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Pancake.hs') diff --git a/Pancake.hs b/Pancake.hs index 174ac29..781e007 100644 --- a/Pancake.hs +++ b/Pancake.hs @@ -115,10 +115,8 @@ readDoc cmd uri = do let reader = case (uriScheme uri, map toLower $ takeExtension $ uriPath uri) of -- some exceptions and special cases (might be better to make -- this configurable) - ("http:", ".php") -> html - ("https:", ".php") -> html - ("http:", "") -> html - ("https:", "") -> html + ("http:", ext) -> http ext + ("https:", ext) -> http ext ("gopher:", ext) -> case uriPath uri of ('/':'1':_) -> gopher ('/':'h':_) -> html @@ -148,6 +146,7 @@ readDoc cmd uri = do Left err -> putErrLn (show err) >> pure Nothing Right (doc, _) -> pure $ pure doc where + http ext = byExtension ext <|> html html = P.getReader "html" plain = pure . P.StringReader . const $ pure . readPlain gopher = pure . P.StringReader . const $ pure . readGopher -- cgit v1.2.3