]> gitweb.michael.orlitzky.com - dead/lwn-epub.git/blobdiff - src/LWN/URI.hs
Add some tests for the article URL construction.
[dead/lwn-epub.git] / src / LWN / URI.hs
index 1cf88263f5a627ecb5851bc6531858fe1b257f3f..7aa4240cf146eee312801881100ce43be087b6e5 100644 (file)
@@ -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 =