Skip to content

Don't strip off too many periods from bulk uploaded filenames#1162

Merged
waxlamp merged 2 commits into
mainfrom
fix-multifile-suffix
Feb 11, 2022
Merged

Don't strip off too many periods from bulk uploaded filenames#1162
waxlamp merged 2 commits into
mainfrom
fix-multifile-suffix

Conversation

@waxlamp
Copy link
Copy Markdown
Member

@waxlamp waxlamp commented Feb 10, 2022

This PR updates the regex that is used to strip off filename suffixes when multiple files are being bulk uploaded. The existing regex was too greedy and would strip off everything after the first period in the name; the new one does so only for the last one.

Closes #838.

`\.[^.]*$` means:
- match a literal period, then
- match any number of non-period characters, then
- match the end of the string

This prevents the regex from stripping the `.10hz.mp4` off of
`video.10hz.mp4`, for example.
@waxlamp waxlamp requested a review from BryonLewis February 10, 2022 23:05
Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing that.
Could be a separate PR but I noticed when Roddy sent that link about the weird truncation of longer filenames given the space we provided.
Could increase truncate-length on the <v-file-input> to like 75 or more given the space that is provided.
https://vuetifyjs.com/en/api/v-file-input/#props-truncate-length

@waxlamp
Copy link
Copy Markdown
Member Author

waxlamp commented Feb 11, 2022

Thanks for fixing that. Could be a separate PR but I noticed when Roddy sent that link about the weird truncation of longer filenames given the space we provided. Could increase truncate-length on the <v-file-input> to like 75 or more given the space that is provided. https://vuetifyjs.com/en/api/v-file-input/#props-truncate-length

Let's do that in a separate PR. For reference, we're talking about #1159.

@waxlamp
Copy link
Copy Markdown
Member Author

waxlamp commented Feb 11, 2022

I forgot to mention it, but technically this regex (and the one it replaces) would strip off a lone period from the end of a filename (e.g., hello. -> hello). I don't think this every happens because logic previous to this step will flag files without a proper extension (maybe? Not sure about this), but the simple fix would be to use + instead of * in the regex (requiring at least one character after the period).

Let me know what you think and we can always make that change in a future PR.

@waxlamp waxlamp merged commit 4bfcdb5 into main Feb 11, 2022
@waxlamp waxlamp deleted the fix-multifile-suffix branch February 11, 2022 14:43
BryonLewis pushed a commit that referenced this pull request Feb 24, 2022
* Use a less greedy regex to strip off file suffixes

`\.[^.]*$` means:
- match a literal period, then
- match any number of non-period characters, then
- match the end of the string

This prevents the regex from stripping the `.10hz.mp4` off of
`video.10hz.mp4`, for example.

* Refactor the file suffix regex into a constant
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.

[BUG] Uploading videos in bulk with periods in title ignores periods

2 participants