Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Issue 1580 - Broken behavior: files containing dots in the name #1582

Merged
merged 1 commit into from
Jul 6, 2023
Merged

Fixing Issue 1580 - Broken behavior: files containing dots in the name #1582

merged 1 commit into from
Jul 6, 2023

Conversation

NishkalankBezawada
Copy link
Contributor

@NishkalankBezawada NishkalankBezawada commented Jul 5, 2023

Q A
Bug fix? [x]
New feature? [ ]
New sample? [ ]
Related issues? fixes #1580

What's in this Pull Request?

Fixing the issue when adding attachments to the ListAttachments control that contain one or more dots (".") in the name, the file type icon is not displayed (ex. PDF, Word, etc.)

Solution

To load the attachment preview in method loadAttachmentPreview we call GetFileImageUrl to fetch the previewImageUrl.

The old code is as below,

    const _fileTypes = _file.FileName.split('.');
    const _fileExtension = _fileTypes[1];

And since, the scenario when we have one or more dots (".") in the file name, the _fileExtension which will get the first element of array from _fileTypes

The corrected code is as below

const _fileExtension = _file.FileName.substr(_file.FileName.lastIndexOf('.') + 1);

this change will get the exact extension of the file.

below are the images from my local workbench.

image

image

image

Thanks,
Nishkalank Bezawada

@joelfmrodrigues joelfmrodrigues merged commit c1e2e0c into pnp:dev Jul 6, 2023
1 check passed
@joelfmrodrigues joelfmrodrigues added this to the 3.15.0 milestone Jul 6, 2023
@NishkalankBezawada NishkalankBezawada deleted the Issue-1580 branch July 6, 2023 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants