refactor: move OC.MimeType to src and add vitest unit tests#55524
Merged
refactor: move OC.MimeType to src and add vitest unit tests#55524
OC.MimeType to src and add vitest unit tests#55524Conversation
c731157 to
b94a1cd
Compare
6 tasks
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
b94a1cd to
7bda1cd
Compare
CarlSchwan
approved these changes
Oct 6, 2025
ShGKme
reviewed
Oct 22, 2025
Comment on lines
+38
to
+48
| if (window.OCA.Theming && gotIcon === null) { | ||
| path = generateUrl('/apps/theming/img/core/filetypes/') | ||
| path += getMimeTypeIcon(mimeType, window.OC.MimeTypeList.files) | ||
| gotIcon = true | ||
| } | ||
|
|
||
| // If we do not yet have an icon fall back to the default | ||
| if (gotIcon === null) { | ||
| path = generateUrl('/core/img/filetypes/') | ||
| path += getMimeTypeIcon(mimeType, window.OC.MimeTypeList.files) | ||
| } |
Contributor
There was a problem hiding this comment.
It is not only moving the function but also changing it
(using suggestion just to show a diff)
Suggested change
| if (window.OCA.Theming && gotIcon === null) { | |
| path = generateUrl('/apps/theming/img/core/filetypes/') | |
| path += getMimeTypeIcon(mimeType, window.OC.MimeTypeList.files) | |
| gotIcon = true | |
| } | |
| // If we do not yet have an icon fall back to the default | |
| if (gotIcon === null) { | |
| path = generateUrl('/core/img/filetypes/') | |
| path += getMimeTypeIcon(mimeType, window.OC.MimeTypeList.files) | |
| } | |
| if (OCA.Theming && gotIcon === null) { | |
| path = OC.generateUrl('/apps/theming/img/core/filetypes/') | |
| path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files) | |
| gotIcon = true | |
| } | |
| // If we do not yet have an icon fall back to the default | |
| if (gotIcon === null) { | |
| path = OC.getRootPath() + '/core/img/filetypes/' | |
| path += OC.MimeType._getFile(mimeType, OC.MimeTypeList.files) | |
| } |
But generateUrl cannot be used here.
/apps/theming/img/- is a PHP route managed by a controller- '/core/img/filetypes/' - is a static file path
In the first case we need to include index.php when no rewrite. But in the second adding index.php breaks the path to the icon.
/index.php/core/img/filetypes/file.svg is not correct.
It must be either imagePath or generateFilePath, or getRootPath like in the original version. But it cannot be generateUrl
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
One step to get rid of Karma tests (aka "jsunit").
Checklist
3. to review, feature component)stable32)