summaryrefslogtreecommitdiff
path: root/src/gmi/gemtext_test.go
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2023-01-23 16:02:35 +0100
committerBrian Picciano <mediocregopher@gmail.com>2023-01-23 16:02:35 +0100
commitc4520f2c84c0d4555bdb02f4ec7b2d1a8bdefca2 (patch)
tree04c343906811c87283d88ae131ac6441265db73f /src/gmi/gemtext_test.go
parentaba69d432959f3c1edc78b1ec2e0891120af5ae2 (diff)
Automatically bridge gemini links to a gateway on http site
Diffstat (limited to 'src/gmi/gemtext_test.go')
-rw-r--r--src/gmi/gemtext_test.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/gmi/gemtext_test.go b/src/gmi/gemtext_test.go
index 23cb97f..75da9df 100644
--- a/src/gmi/gemtext_test.go
+++ b/src/gmi/gemtext_test.go
@@ -2,6 +2,7 @@ package gmi
import (
"bytes"
+ "net/url"
"strconv"
"testing"
@@ -10,6 +11,8 @@ import (
func TestGemtextToMarkdown(t *testing.T) {
+ gmiGateway, _ := url.Parse("https://gateway.com/x/")
+
tests := []struct {
in, exp string
}{
@@ -37,13 +40,25 @@ func TestGemtextToMarkdown(t *testing.T) {
in: "=> img.png description is here ",
exp: "![description is here](img.png)\n",
},
+ {
+ in: "=> gemini://somewhere.com/foo Somewhere",
+ exp: "[Somewhere](https://gateway.com/x/somewhere.com/foo)\n",
+ },
+ {
+ in: "=> gemini://somewhere.com:420/foo Somewhere",
+ exp: "[Somewhere](https://gateway.com/x/somewhere.com:420/foo)\n",
+ },
+ {
+ in: "=> gemini://somewhere.com:420/foo?bar=baz Somewhere",
+ exp: "[Somewhere](https://gateway.com/x/somewhere.com:420/foo?bar=baz)\n",
+ },
}
for i, test := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
got := new(bytes.Buffer)
- err := GemtextToMarkdown(got, bytes.NewBufferString(test.in))
+ err := GemtextToMarkdown(got, bytes.NewBufferString(test.in), gmiGateway)
assert.NoError(t, err)
assert.Equal(t, test.exp, got.String())
})