fix: metadata mismatch if file name contains % while uploading to OneDrive/SharePoint

This commit is contained in:
HFO4
2022-10-15 09:20:25 +08:00
parent 6b0b44f6d0
commit 560097145b
2 changed files with 27 additions and 7 deletions

View File

@@ -138,13 +138,28 @@ func TestRequest(t *testing.T) {
func TestFileInfo_GetSourcePath(t *testing.T) {
asserts := assert.New(t)
fileInfo := FileInfo{
Name: "文件名.jpg",
ParentReference: parentReference{
Path: "/drive/root:/123/321",
},
// 成功
{
fileInfo := FileInfo{
Name: "%e6%96%87%e4%bb%b6%e5%90%8d.jpg",
ParentReference: parentReference{
Path: "/drive/root:/123/32%201",
},
}
asserts.Equal("123/32 1/%e6%96%87%e4%bb%b6%e5%90%8d.jpg", fileInfo.GetSourcePath())
}
// 失败
{
fileInfo := FileInfo{
Name: "123.jpg",
ParentReference: parentReference{
Path: "/drive/root:/123/%e6%96%87%e4%bb%b6%e5%90%8g",
},
}
asserts.Equal("", fileInfo.GetSourcePath())
}
asserts.Equal("123/321/文件名.jpg", fileInfo.GetSourcePath())
}
func TestClient_GetRequestURL(t *testing.T) {