Skip to content

Commit

Permalink
fix(files): better archive file check (#2639)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmcg committed Mar 30, 2022
1 parent 69825db commit 7cb2bbe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
19 changes: 4 additions & 15 deletions components/views/files/file/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,8 @@ import ContextMenu from '~/components/mixins/UI/ContextMenu'
import { Item } from '~/libraries/Files/abstracts/Item.abstract'
import { Directory } from '~/libraries/Files/Directory'
import { Fil } from '~/libraries/Files/Fil'
import { ModalWindows } from '~/store/ui/types'
declare module 'vue/types/vue' {
interface Vue {
like: () => void
share: () => void
rename: () => void
remove: () => void
$filesize: (item: number) => string
linkHover: boolean
heartHover: boolean
}
}
import { ContextMenuItem, ModalWindows } from '~/store/ui/types'
import { isMimeArchive } from '~/utilities/FileType'
export default Vue.extend({
components: {
Expand Down Expand Up @@ -75,9 +64,9 @@ export default Vue.extend({
* @returns {boolean} if item is archive file type
*/
isArchive(): boolean {
return Boolean(this.item.name.match(this.$Config.regex.archive))
return isMimeArchive(this.item.type)
},
contextMenuValues() {
contextMenuValues(): ContextMenuItem[] {
return [
{
text: this.item.liked
Expand Down
7 changes: 4 additions & 3 deletions components/views/files/row/Row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
} from 'satellite-lucide-icons'
import ContextMenu from '~/components/mixins/UI/ContextMenu'
import { Item } from '~/libraries/Files/abstracts/Item.abstract'
import { ModalWindows } from '~/store/ui/types'
import { ContextMenuItem, ModalWindows } from '~/store/ui/types'
import { isMimeArchive } from '~/utilities/FileType'
export default Vue.extend({
components: {
Expand Down Expand Up @@ -46,9 +47,9 @@ export default Vue.extend({
* @returns {boolean} if item is archive file type
*/
isArchive(): boolean {
return Boolean(this.item.name.match(this.$Config.regex.archive))
return isMimeArchive(this.item.type)
},
contextMenuValues() {
contextMenuValues(): ContextMenuItem[] {
return [
{
text: this.item.liked
Expand Down
2 changes: 0 additions & 2 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ export const Config = {
regex: {
// identify if a file type is embeddable image
image: '^.*.(apng|avif|gif|jpg|jpeg|jfif|pjpeg|pjp|png|svg|webp)$',
// determine if filetype is archive
archive: '^.*.(zip|vnd.rar|x-7z-compressed)$',
// check for empty string or spaces/nbsp
empty: /^\s*$/,
// Regex to check if string contains only emoji's.
Expand Down

0 comments on commit 7cb2bbe

Please sign in to comment.