summaryrefslogtreecommitdiff
path: root/internal/summary/summary_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-01-19 09:43:57 +0200
committerPaul Buetow <paul@buetow.org>2025-01-19 09:43:57 +0200
commitf520f130d266691301940f357967108d6a8cb7da (patch)
tree26cca0c78b3884d867db836ec1607f0b909c2219 /internal/summary/summary_test.go
parent54e617e09027c8339a0f9096d61739ad353a5cf4 (diff)
internal gemini capsule links stay gemini://
Diffstat (limited to 'internal/summary/summary_test.go')
-rw-r--r--internal/summary/summary_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/summary/summary_test.go b/internal/summary/summary_test.go
new file mode 100644
index 0000000..4b33609
--- /dev/null
+++ b/internal/summary/summary_test.go
@@ -0,0 +1,23 @@
+package summary
+
+import "testing"
+
+func TestGemtextLink(t *testing.T) {
+ const geminiCapsule = "foo.zone"
+
+ table := map[string]string{
+ "http://example.com": "=> http://example.com example.com",
+ "https://example.org": "=> https://example.org example.org",
+ "https://example.org/some/very/long/link/here?with=a&free=of&parameters=here": "=> https://example.org/some/very/long/link/here?with=a&free=of&parameters=here example.org/s...rameters=here",
+ "http://foo.zone": "=> gemini://foo.zone foo.zone",
+ "https://foo.zone": "=> gemini://foo.zone foo.zone",
+ "beer://foo.zone": "=> beer://foo.zone foo.zone",
+ "https://foo.zone/some/very/long/link/here?with=a&free=of&parameters=here": "=> gemini://foo.zone/some/very/long/link/here?with=a&free=of&parameters=here foo.zone/some...rameters=here",
+ }
+
+ for url, expected := range table {
+ if result := gemtextLink(geminiCapsule, url, 30); result != expected {
+ t.Errorf("Expected '%s' but got '%s' with input '%s'", expected, result, url)
+ }
+ }
+}