mux: Remove support for handling schemes
Also fix redirection to subtree roots for wildcard patterns and patterns without a host name.
This commit is contained in:
+6
-181
@@ -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},
|
||||
@@ -102,170 +102,6 @@ func TestMuxMatch(t *testing.T) {
|
||||
{"http://example.com/subtree/", false},
|
||||
},
|
||||
},
|
||||
{
|
||||
// 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",
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user