feat: Implement robots.txt parser

This commit is contained in:
2024-10-23 09:26:39 +03:00
parent 17ef03d621
commit e51d84cad8
2 changed files with 71 additions and 0 deletions

25
gemini/robots_test.go Normal file
View File

@@ -0,0 +1,25 @@
package gemini
import (
"testing"
"reflect"
)
func TestParseRobotsTxt(t *testing.T) {
input := `User-agent: *
Disallow: /cgi-bin/wp.cgi/view
Disallow: /cgi-bin/wp.cgi/media
User-agent: googlebot
Disallow: /admin/`
expected := []string{
"gemini://example.com/cgi-bin/wp.cgi/view",
"gemini://example.com/cgi-bin/wp.cgi/media",
}
result := ParseRobotsTxt(input, "example.com")
if !reflect.DeepEqual(result, expected) {
t.Errorf("ParseRobotsTxt() = %v, want %v", result, expected)
}
}