1
0
mirror of https://github.com/rclone/rclone.git synced 2025-11-23 21:44:49 +02:00

lib/rest: add URLPathEscapeAll to URL escape as many chars as possible

This commit is contained in:
Nick Craig-Wood
2025-09-02 16:13:28 +01:00
parent dd75af6a18
commit 1f14b6aa35
2 changed files with 46 additions and 0 deletions

View File

@@ -59,3 +59,27 @@ func TestURLPathEscape(t *testing.T) {
assert.Equal(t, test.want, got, fmt.Sprintf("Test %d path = %q", i, test.path))
}
}
func TestURLPathEscapeAll(t *testing.T) {
tests := []struct {
in string
want string
}{
{"", ""},
{"/hello.txt", "/hello%2Etxt"},
{"With Space", "With%20Space"},
{"With Colon:", "With%20Colon%3A"},
{"With Percent%", "With%20Percent%25"},
{"abc/XYZ123", "abc/XYZ123"},
{"hello world", "hello%20world"},
{"$test", "%24test"},
{"ümlaut", "%C3%BCmlaut"},
{"", ""},
{" /?", "%20/%3F"},
}
for _, test := range tests {
got := URLPathEscapeAll(test.in)
assert.Equal(t, test.want, got)
}
}