From 5ca42405c426ad03b279347b4a5c8deda7049d49 Mon Sep 17 00:00:00 2001 From: Michael Lambert Date: Sat, 15 Feb 2020 09:30:10 +1100 Subject: [PATCH] Detect slashes on bucketPrefix and fix as required --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e28c857..bccb9b1 100644 --- a/index.js +++ b/index.js @@ -200,8 +200,8 @@ class ServerlessS3Sync { const servicePath = this.servicePath; const promises = s3Sync.map( async (s) => { let bucketPrefix = ''; - if (s.hasOwnProperty('bucketPrefix')) { - bucketPrefix = s.bucketPrefix; + if (s.hasOwnProperty('bucketPrefix') && s.bucketPrefix.length > 0) { + bucketPrefix = s.bucketPrefix.replace(/\/?$/, '').replace(/^\/?/, '/') } let acl = 'private'; if (s.hasOwnProperty('acl')) {