Skip to content

Commit

Permalink
Fix case insensitive regexp matching, refs #7
Browse files Browse the repository at this point in the history
  • Loading branch information
cmfcmf committed Nov 27, 2019
1 parent b3a328f commit 5408480
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,10 @@ export default class UploadHandler {
}

private findFileCaseInsensitive(zip: JSZip, path: string): JSZip.JSZipObject {
const caseInsensitiveFileName = new RegExp(escapeStringRegexp(path), "i");
const caseInsensitiveFileName = new RegExp(
`^${escapeStringRegexp(path)}$`,
"i"
);
const file = zip.file(caseInsensitiveFileName)[0];
if (file === undefined) {
throw new Error(`Could not find file ${path}.`);
Expand All @@ -486,7 +489,10 @@ export default class UploadHandler {
}

private hasFolderCaseInsensitive(zip: JSZip, path: string): boolean {
const caseInsensitiveFolderName = new RegExp(escapeStringRegexp(path), "i");
const caseInsensitiveFolderName = new RegExp(
`^${escapeStringRegexp(path)}$`,
"i"
);
return zip.folder(caseInsensitiveFolderName)[0] !== undefined;
}
}

0 comments on commit 5408480

Please sign in to comment.