From 2dc65cee797a40577dfa7c13a8ef9571e91a0bdc Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 31 Dec 2020 11:06:41 -0800 Subject: [PATCH] Revert "Revert "Allow forward slash string separators in skin file paths."" This reverts commit 01c26f3c6a8e34ff8bf274c8de82954079615a93. --- packages/webamp/js/skinParserUtils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/webamp/js/skinParserUtils.ts b/packages/webamp/js/skinParserUtils.ts index cc84b625..3809ccb3 100644 --- a/packages/webamp/js/skinParserUtils.ts +++ b/packages/webamp/js/skinParserUtils.ts @@ -11,7 +11,11 @@ export const getFileExtension = (fileName: string): string | null => { }; function getFilenameRegex(base: string, ext: string): RegExp { - return new RegExp(`^(.*/)?${base}.(${ext})$`, "i"); + // Note: The four slashes: \\\\ ultimately represent a single escaped slash in + // the regex ("\\"), however each itself needs to be escaped so that + // JavaScript does not interperate it as an escape character in the string + // literal. Wonderful. + return new RegExp(`^(.*[/\\\\])${base}.(${ext})$`, "i"); } export async function getFileFromZip( @@ -40,6 +44,7 @@ export async function getFileFromZip( // the last file that JSZip extracted. const lastFile = files[files.length - 1]; + console.log(`Looking for ${fileName} and got ${lastFile.name}`); try { const contents = await lastFile.async(mode); return { contents, name: lastFile.name };