fix(module: upload): Use System.IO.Path.GetExtension instead of Substring to support filenames without extensions (#3553) (#3554)
Co-authored-by: Noah Potash <noah.potash@outbreaklabs.com>
This commit is contained in:
Родитель
cb47c1a244
Коммит
dade3d08e1
|
@ -137,7 +137,7 @@ namespace AntDesign.Internal
|
|||
foreach (var fileItem in flist)
|
||||
{
|
||||
var fileName = fileItem.FileName;
|
||||
fileItem.Ext = fileItem.FileName.Substring(fileName.LastIndexOf('.'));
|
||||
fileItem.Ext = System.IO.Path.GetExtension(fileItem.FileName);
|
||||
var id = Guid.NewGuid().ToString();
|
||||
if (Upload.BeforeUpload != null && !Upload.BeforeUpload.Invoke(fileItem))
|
||||
{
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
@inherits AntDesignTestBase
|
||||
@using System.IO
|
||||
@using AngleSharp.Html.Dom
|
||||
@using AngleSharp.Io.Dom
|
||||
@inherits AntDesignTestBase
|
||||
@code {
|
||||
[Fact]
|
||||
public void Renders_basic_upload()
|
||||
|
@ -60,4 +63,21 @@
|
|||
</div>
|
||||
</span>);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Handles_filenames_without_extension()
|
||||
{
|
||||
JSInterop.SetupVoid(JSInteropConstants.AddFileClickEventListener, _ => true);
|
||||
JSInterop.SetupVoid(JSInteropConstants.UploadFile, _ => true).SetCanceled();
|
||||
JSInterop.SetupVoid(JSInteropConstants.ClearFile, _ => true);
|
||||
|
||||
JSInterop.Setup<List<UploadFileItem>>(JSInteropConstants.GetFileInfo, _ => true).SetResult(new List<UploadFileItem> { new UploadFileItem { FileName = "test" } });
|
||||
|
||||
var cut = Context.Render(@<Upload>some content</Upload>);
|
||||
|
||||
var inputElement = ((AngleSharpWrappers.HtmlInputElementWrapper)cut.Find("input")).WrappedElement;
|
||||
|
||||
Func<Task> act = () => inputElement.ChangeAsync(new ChangeEventArgs() { Value = "ignored" });
|
||||
await act.Should().NotThrowAsync();
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче