Skip to content

Commit

Permalink
fix: allow for zip uploads without suffix
Browse files Browse the repository at this point in the history
A file is considered a potential zip file if it does not contain a
period.  Since zip files are not named with a period, but it is possible
to upload such files using drag and drop.
  • Loading branch information
aalemayhu committed Dec 2, 2024
1 parent 6f8af2d commit dfd0534
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/lib/storage/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ export const isImageFileEmbedable = (url: string) => {
export const isCSVFile = (fileName: string) => /.csv$/i.exec(fileName);

export const isPDFFile = (fileName: string) => /.pdf$/i.exec(fileName);

/**
* A file is considered a potential zip file if it does not contain a period.
* Since zip files are not named with a period, but it is possible to upload such files using drag and drop.
* @param filename
* @returns
*/
export const isPotentialZipFile = (filename: string): boolean =>
!filename.includes('.');
8 changes: 6 additions & 2 deletions src/usecases/uploads/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Settings from '../../lib/parser/Settings';
import Package from '../../lib/parser/Package';
import fs from 'fs';
import { PrepareDeck } from '../../lib/parser/PrepareDeck';
import { isZIPFile } from '../../lib/storage/checks';
import { isPotentialZipFile, isZIPFile } from '../../lib/storage/checks';
import { getPackagesFromZip } from './getPackagesFromZip';
import Workspace from '../../lib/parser/WorkSpace';
import { isZipContentFileSupported } from './isZipContentFileSupported';
Expand Down Expand Up @@ -40,7 +40,11 @@ function doGenerationWork(data: GenerationData) {
const pkg = new Package(d.name);
packages = packages.concat(pkg);
}
} else if (isZIPFile(filename) || isZIPFile(key)) {
} else if (
isZIPFile(filename) ||
isZIPFile(key) ||
isPotentialZipFile(filename)
) {
const { packages: extraPackages } = await getPackagesFromZip(
fileContents,
paying,
Expand Down

0 comments on commit dfd0534

Please sign in to comment.