X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FLWN%2FURI.hs;h=7aa4240cf146eee312801881100ce43be087b6e5;hb=35e0551101fa2267f28ff434a6006a3612ad54c9;hp=9e7c7d944963a0a52b51b2b6b48aeb48ef57373d;hpb=abd072d7a4b825cdfc7aaa49ef3c7897ffad3bf2;p=dead%2Flwn-epub.git diff --git a/src/LWN/URI.hs b/src/LWN/URI.hs index 9e7c7d9..7aa4240 100644 --- a/src/LWN/URI.hs +++ b/src/LWN/URI.hs @@ -14,7 +14,7 @@ import Network.URI ( import Test.HUnit (Assertion, assertEqual) import Test.Framework (Test, testGroup) import Test.Framework.Providers.HUnit (testCase) -import Text.Regex.Posix +import Text.Regex.Posix ((=~)) -- Distinguish between URLs (Strings) and URIs as provided by the -- Network.URI module. @@ -40,6 +40,19 @@ http_port uri = parse_result = uriAuthority uri +make_https :: URL -> URL +make_https url = + case parse_result of + Nothing -> url -- Shrug? + Just uri -> + if http uri then + show $ uri { uriScheme = "https:" } + else + url -- Leave non-http URLs alone. + where + parse_result = parseURIReference url + + -- | Does this URI use an HTTPS-compatible port? https_port :: URI -> Bool https_port uri =