From 6ec6bf08c8c786b6b4d0c58c12c9e8d92d11c15d Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 20 Apr 2018 17:29:55 -0700 Subject: [PATCH] Backup E2E test: Normalize paths because glob returns / on WIN --- test/backup_test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/backup_test.js b/test/backup_test.js index 5ccf53165..976eb6460 100644 --- a/test/backup_test.js +++ b/test/backup_test.js @@ -266,11 +266,13 @@ describe('Backup', () => { return _.omit(model, ['id']); } - const slash = path.sep === '/' ? '\\/' : '\\\\'; - const twoSlashes = new RegExp(`.*${slash}.*${slash}.*`); + // On windows, attachmentsPath has a normal windows path format (\ separators), but + // glob returns only /. We normalize to / separators for our manipulations. + const twoSlashes = /[^/]*\/[^/]*\/[^/]*/; + const normalizedBase = attachmentsPath.replace(/\\/g, '/'); function removeDirs(dirs) { return _.filter(dirs, (fullDir) => { - const dir = fullDir.replace(attachmentsPath, ''); + const dir = fullDir.replace(normalizedBase, ''); return twoSlashes.test(dir); }); }