Skip to content

Commit 2d71ec3

Browse files
Check for last instance of .js extension in filename (#709)
* Check for last instance of .js extension in filename * adding clarifying comments for change * Update scripts/upload-assets.js Co-authored-by: Seth Silesky <5115498+silesky@users.noreply.github.com> Co-authored-by: Seth Silesky <5115498+silesky@users.noreply.github.com>
1 parent e663d06 commit 2d71ec3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

scripts/upload-assets.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,18 @@ async function uploadAssets() {
110110
const type = f[1]; // get integration name
111111
const integration = f[2]; // get integration name
112112
const file = f[f.length - 1];
113-
const clientName = file.substring(0, file.indexOf('.'));
113+
/**
114+
* Supporting filenames where analytics.js is prepended to the bundle name.
115+
* Filename formats typically end in .js or .js.gz
116+
* For example:
117+
* - asfghemUtZGVkdXBsaWNhdGU.js.gz
118+
* - analytics.js-middleware-braze-foo.js
119+
* - analytics.js-middleware-braze-foo.js.gz
120+
* - analytics.js-middleware-braze-foo.dynamic.js.gz
121+
*/
122+
const clientName = file.includes('analytics.js-') ?
123+
file.substring(0, file.lastIndexOf('.js')) :
124+
file.substring(0, file.indexOf('.'));
114125
const bufferClientName = Buffer.from(clientName).toString('base64').replace(/=/g, '');
115126
const bufferFile = file.replace(clientName, bufferClientName);
116127

0 commit comments

Comments
 (0)