fix: address all review findings from PR #17
- Rename all remaining url locals to reqURL (consistency) - Use http.MethodGet/http.MethodPost constants - Document escapePath: relative paths only, double-encoding expected - Add TestEscapePath with 7 edge cases (empty, spaces, #, deep, encoded)
This commit is contained in:
@@ -294,3 +294,27 @@ func TestGetAllFilesInPath_File(t *testing.T) {
|
||||
t.Errorf("unexpected content: %q", files["README.md"])
|
||||
}
|
||||
}
|
||||
|
||||
func TestEscapePath(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
input string
|
||||
want string
|
||||
}{
|
||||
{"simple", "src/main.go", "src/main.go"},
|
||||
{"spaces", "my dir/my file.go", "my%20dir/my%20file.go"},
|
||||
{"special chars", "path/file#1.txt", "path/file%231.txt"},
|
||||
{"empty", "", ""},
|
||||
{"single segment", "README.md", "README.md"},
|
||||
{"nested deep", "a/b/c/d.md", "a/b/c/d.md"},
|
||||
{"already encoded", "path/file%20name.go", "path/file%2520name.go"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got := escapePath(tt.input)
|
||||
if got != tt.want {
|
||||
t.Errorf("escapePath(%q) = %q, want %q", tt.input, got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user