Safe filename (#16)

Fix #15.

Reviewed-on: https://gitea.com/gitea/act/pulls/16
Reviewed-by: Lunny Xiao <[email protected]>
Co-authored-by: Jason Song <[email protected]>
Co-committed-by: Jason Song <[email protected]>
This commit is contained in:
Jason Song authored and Lunny Xiao committed 2023-02-24 10:17:36 +08:00
1 parent dca7801682
commit 84b6649b8b
2 files changed
+36 -1

No files matched your search

+21
View File
@@ -717,3 +717,24 @@ func Test_newRemoteAction(t *testing.T) {
})
}
}
func Test_safeFilename(t *testing.T) {
tests := []struct {
s string
want string
}{
{
s: "https://test.com/test/",
want: "https---test.com-test-",
},
{
s: `<>:"/\|?*`,
want: "---------",
},
}
for _, tt := range tests {
t.Run(tt.s, func(t *testing.T) {
assert.Equalf(t, tt.want, safeFilename(tt.s), "safeFilename(%v)", tt.s)
})
}
}