Repos / mcross / 010368c363
commit 010368c363c793c6844912b5a8465d640da65983
Author: Frederick Yin <fkfd@macaw.me>
Date:   Fri Jun 5 15:47:06 2020 +0800

    Parse absolute url links with scheme omitted
    
    This enables McRoss to parse links that start with "//", which is just
    "gemini://" but with "gemini:" omitted but implied, in accordance with
    the Gemini spec, section 1.2.
    
    Additionally, this patch takes McRoss all the way to #0008 of the
    conman.org torture test, instead of #0002.

diff --git a/src/mcross/gui/model.py b/src/mcross/gui/model.py
index 4549ba1..23667bd 100644
--- a/src/mcross/gui/model.py
+++ b/src/mcross/gui/model.py
@@ -21,6 +21,7 @@
 
 => relative/ Relative link
 => /relative/ Relative link starting with "/"
+=> //republic.circumlunar.space/ Absolute link with scheme omitted
 => https://lists.orbitalfox.eu/listinfo/gemini?foo=bar HTTP link
 
 ## Codes
diff --git a/src/mcross/transport.py b/src/mcross/transport.py
index c925baa..d25f7ba 100644
--- a/src/mcross/transport.py
+++ b/src/mcross/transport.py
@@ -79,6 +79,11 @@ def parse(cls, text, current_url):
         if protocol:
             raise UnsupportedProtocolError(protocol)
 
+        # absolute url with scheme omitted
+        # for example, "//example.com/foo"
+        if text.startswith("//"):
+            return cls.parse_absolute_url("gemini:" + text)
+
         if current_url is None:
             raise NonAbsoluteUrlWithoutContextError(text)