fix: metadata mismatch if file name contains % while uploading to OneDrive/SharePoint (#1301)

This commit is contained in:
HFO4
2022-10-08 19:09:51 +08:00
parent 644a326580
commit f431eb0cbd
3 changed files with 12 additions and 33 deletions

View File

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