From 3b63e2bb67b82b6317ac48d054c6766d3f9a5419 Mon Sep 17 00:00:00 2001 From: defanor Date: Sun, 29 Oct 2017 01:14:08 +0300 Subject: Fix gopher URI parsing Using `splitDirectories` for its paths (types + selectors) was a bad idea, particularly leading to misbehaviour with "hURL:" redirects. --- Pancake.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Pancake.hs') diff --git a/Pancake.hs b/Pancake.hs index 939ca6d..87d5700 100644 --- a/Pancake.hs +++ b/Pancake.hs @@ -118,15 +118,15 @@ readDoc cmd uri = do ("https:", ".php") -> html ("http:", "") -> html ("https:", "") -> html - ("gopher:", ext) -> case splitDirectories $ uriPath uri of - ("/":"1":_) -> gopher - ("/":"h":_) -> html + ("gopher:", ext) -> case uriPath uri of + ('/':'1':_) -> gopher + ('/':'h':_) -> html -- "0" should indicate plain text, but it's also the most -- suitable option for non-html markup. Not sure about this -- approach, but it's similar to ignoring HTTP content-type, -- and will do for now: better to render documents nicely -- when possible. - ("/":"0":_) -> byExtension ext <|> plain + ('/':'0':_) -> byExtension ext <|> plain -- unknown or unrecognized item type _ -> byExtension ext <|> gopher (_, ext) -> byExtension ext <|> plain -- cgit v1.2.3