diff options
| author | Adnan Maolood <[email protected]> | 2021-06-26 18:50:05 -0400 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-06-26 18:50:09 -0400 |
| commit | fb0d4d24bd27aee5579b8f7ec417775c4b7e74d7 (patch) | |
| tree | dfdd20ad9a24a9b3427d33a2b9603213a8209779 /mux_test.go | |
| parent | fs: Avoid equality check if lengths don't match (diff) | |
| download | go-gemini-fb0d4d24bd27aee5579b8f7ec417775c4b7e74d7.tar.xz go-gemini-fb0d4d24bd27aee5579b8f7ec417775c4b7e74d7.zip | |
mux: Remove support for handling schemes
Also fix redirection to subtree roots for wildcard patterns and patterns
without a host name.
Diffstat (limited to 'mux_test.go')
| -rw-r--r-- | mux_test.go | 187 |
1 files changed, 6 insertions, 181 deletions
diff --git a/mux_test.go b/mux_test.go index 47e1ca7..2a2101f 100644 --- a/mux_test.go +++ b/mux_test.go @@ -21,7 +21,7 @@ func TestMuxMatch(t *testing.T) { Matches []Match }{ { - // scheme: gemini, hostname: *, path: /* + // hostname: *, path: /* Pattern: "/", Matches: []Match{ {"gemini://example.com/path", true}, @@ -34,7 +34,7 @@ func TestMuxMatch(t *testing.T) { }, }, { - // scheme: gemini, hostname: *, path: /path + // hostname: *, path: /path Pattern: "/path", Matches: []Match{ {"gemini://example.com/path", true}, @@ -47,7 +47,7 @@ func TestMuxMatch(t *testing.T) { }, }, { - // scheme: gemini, hostname: *, path: /subtree/* + // hostname: *, path: /subtree/* Pattern: "/subtree/", Matches: []Match{ {"gemini://example.com/subtree/", true}, @@ -62,7 +62,7 @@ func TestMuxMatch(t *testing.T) { }, }, { - // scheme: gemini, hostname: example.com, path: /* + // hostname: example.com, path: /* Pattern: "example.com", Matches: []Match{ {"gemini://example.com/path", true}, @@ -75,7 +75,7 @@ func TestMuxMatch(t *testing.T) { }, }, { - // scheme: gemini, hostname: example.com, path: /path + // hostname: example.com, path: /path Pattern: "example.com/path", Matches: []Match{ {"gemini://example.com/path", true}, @@ -88,7 +88,7 @@ func TestMuxMatch(t *testing.T) { }, }, { - // scheme: gemini, hostname: example.com, path: /subtree/* + // hostname: example.com, path: /subtree/* Pattern: "example.com/subtree/", Matches: []Match{ {"gemini://example.com/subtree/", true}, @@ -103,170 +103,6 @@ func TestMuxMatch(t *testing.T) { }, }, { - // scheme: http, hostname: example.com, path: /* - Pattern: "http://example.com", - Matches: []Match{ - {"http://example.com/path", true}, - {"http://example.com/", true}, - {"http://example.com/path.gmi", true}, - {"http://example.com/path/", true}, - {"http://example.org/path", false}, - {"gemini://example.com/path", false}, - {"gemini://example.org/path", false}, - }, - }, - { - // scheme: http, hostname: example.com, path: /path - Pattern: "http://example.com/path", - Matches: []Match{ - {"http://example.com/path", true}, - {"http://example.com/", false}, - {"http://example.com/path.gmi", false}, - {"http://example.com/path/", false}, - {"http://example.org/path", false}, - {"gemini://example.com/path", false}, - {"gemini://example.org/path", false}, - }, - }, - { - // scheme: http, hostname: example.com, path: /subtree/* - Pattern: "http://example.com/subtree/", - Matches: []Match{ - {"http://example.com/subtree/", true}, - {"http://example.com/subtree/nested/", true}, - {"http://example.com/subtree/nested/file", true}, - {"http://example.org/subtree/", false}, - {"http://example.org/subtree/nested/", false}, - {"http://example.org/subtree/nested/file", false}, - {"http://example.com/subtree", false}, - {"http://www.example.com/subtree/", false}, - {"gemini://example.com/subtree/", false}, - }, - }, - { - // scheme: *, hostname: example.com, path: /* - Pattern: "//example.com", - Matches: []Match{ - {"gemini://example.com/path", true}, - {"gemini://example.com/", true}, - {"gemini://example.com/path.gmi", true}, - {"gemini://example.com/path/", true}, - {"gemini://example.org/path", false}, - {"http://example.com/path", true}, - {"http://example.org/path", false}, - }, - }, - { - // scheme: *, hostname: example.com, path: /path - Pattern: "//example.com/path", - Matches: []Match{ - {"gemini://example.com/path", true}, - {"gemini://example.com/", false}, - {"gemini://example.com/path.gmi", false}, - {"gemini://example.com/path/", false}, - {"gemini://example.org/path", false}, - {"http://example.com/path", true}, - {"http://example.org/path", false}, - }, - }, - { - // scheme: *, hostname: example.com, path: /subtree/* - Pattern: "//example.com/subtree/", - Matches: []Match{ - {"gemini://example.com/subtree/", true}, - {"gemini://example.com/subtree/nested/", true}, - {"gemini://example.com/subtree/nested/file", true}, - {"gemini://example.org/subtree/", false}, - {"gemini://example.org/subtree/nested/", false}, - {"gemini://example.org/subtree/nested/file", false}, - {"gemini://example.com/subtree", false}, - {"gemini://www.example.com/subtree/", false}, - {"http://example.com/subtree/", true}, - }, - }, - { - // scheme: http, hostname: *, path: /* - Pattern: "http://", - Matches: []Match{ - {"http://example.com/path", true}, - {"http://example.com/", true}, - {"http://example.com/path.gmi", true}, - {"http://example.com/path/", true}, - {"http://example.org/path", true}, - {"gemini://example.com/path", false}, - {"gemini://example.org/path", false}, - }, - }, - { - // scheme: http, hostname: *, path: /path - Pattern: "http:///path", - Matches: []Match{ - {"http://example.com/path", true}, - {"http://example.com/", false}, - {"http://example.com/path.gmi", false}, - {"http://example.com/path/", false}, - {"http://example.org/path", true}, - {"gemini://example.com/path", false}, - {"gemini://example.org/path", false}, - }, - }, - { - // scheme: http, hostname: *, path: /subtree/* - Pattern: "http:///subtree/", - Matches: []Match{ - {"http://example.com/subtree/", true}, - {"http://example.com/subtree/nested/", true}, - {"http://example.com/subtree/nested/file", true}, - {"http://example.org/subtree/", true}, - {"http://example.org/subtree/nested/", true}, - {"http://example.org/subtree/nested/file", true}, - {"http://example.com/subtree", false}, - {"http://www.example.com/subtree/", true}, - {"gemini://example.com/subtree/", false}, - }, - }, - { - // scheme: *, hostname: *, path: /* - Pattern: "//", - Matches: []Match{ - {"gemini://example.com/path", true}, - {"gemini://example.com/", true}, - {"gemini://example.com/path.gmi", true}, - {"gemini://example.com/path/", true}, - {"gemini://example.org/path", true}, - {"http://example.com/path", true}, - {"http://example.org/path", true}, - }, - }, - { - // scheme: *, hostname: *, path: /path - Pattern: "///path", - Matches: []Match{ - {"gemini://example.com/path", true}, - {"gemini://example.com/", false}, - {"gemini://example.com/path.gmi", false}, - {"gemini://example.com/path/", false}, - {"gemini://example.org/path", true}, - {"http://example.com/path", true}, - {"http://example.org/path", true}, - }, - }, - { - // scheme: *, hostname: *, path: /subtree/* - Pattern: "///subtree/", - Matches: []Match{ - {"gemini://example.com/subtree/", true}, - {"gemini://example.com/subtree/nested/", true}, - {"gemini://example.com/subtree/nested/file", true}, - {"gemini://example.org/subtree/", true}, - {"gemini://example.org/subtree/nested/", true}, - {"gemini://example.org/subtree/nested/file", true}, - {"gemini://example.com/subtree", false}, - {"gemini://www.example.com/subtree/", true}, - {"http://example.com/subtree/", true}, - }, - }, - { // scheme: gemini, hostname: *.example.com, path: /* Pattern: "*.example.com", Matches: []Match{ @@ -277,17 +113,6 @@ func TestMuxMatch(t *testing.T) { {"http://www.example.com/", false}, }, }, - { - // scheme: http, hostname: *.example.com, path: /* - Pattern: "http://*.example.com", - Matches: []Match{ - {"http://mail.example.com/", true}, - {"http://www.example.com/index.gmi", true}, - {"http://example.com/", false}, - {"http://a.b.example.com/", false}, - {"gemini://www.example.com/", false}, - }, - }, } for i, test := range tests { |