~nhanb/mcross-devel

Parse absolute url links with scheme omitted v1 APPLIED

Frederick Yin: 1
 Parse absolute url links with scheme omitted

 2 files changed, 6 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~nhanb/mcross-devel/patches/10899/mbox | git am -3
Learn more about email & git

[PATCH] Parse absolute url links with scheme omitted Export this patch

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.
---
 src/mcross/gui/model.py | 1 +
 src/mcross/transport.py | 5 +++++
 2 files changed, 6 insertions(+)

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 @@ DEMO_TEXT = """\

=> 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 @@ class GeminiUrl:
        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)

-- 
2.27.0
Thanks for the patch. It's merged now.

Sorry for the spam I sent earlier to the mailing list. I was trying to 
make fastmail's webmail play well with mailing lists and gave up. It 
won't happen again. (using thunderbird now)