ottokruse / s3-spa-upload

Upload a single page application to S3 with the right content-type and cache-control meta-data
22 stars 3 forks source link

Uploads strip first character of filename if `<directory>` on command line is `.` #5

Closed tripplilley closed 1 year ago

tripplilley commented 1 year ago

Because the contents of ${dir} are not escaped when constructing regexp, any regex special characters present in the directory name passed in command line args will cause the filePath.replace(...) expression used to construct the key arg for uploadToS3 to behave unexpectedly.

Given README.md in the current directory and the following invocation:

s3-spa-upload . example-bucket --prefix dest/

The result will be example-bucket/dest/EADME.md.

Although escaping the dir variable when constructing regexp would work, it's probably better to use the path module to deconstruct the filePath and construct the key.

ottokruse commented 1 year ago

Thanks for the report! This should be fixed in v2.0.0

ottokruse commented 1 year ago

Just published v2.0.2 which you should use instead of v2.0.0 (in 2.0.0 I forgot to take out an artificial wait that I added for testing 🤦 )