qoomon / aws-s3-bucket-browser

Single page application to browse AWS S3 bucket content
https://qoomon.github.io/aws-s3-bucket-browser/index.html?bucket=https://s3.amazonaws.com/spacenet-dataset#
MIT License
246 stars 85 forks source link

fix: Add custom path encoder #52

Closed korhox closed 1 year ago

korhox commented 1 year ago

As of issue #38 / delimeters was encoded to %2F. This was fixed by changing encodeURIComponent to encodeURI. However, this raised an issue of + signs not working in directory names and this was fixed in PR #41 by changing these functions back to the original.

The difference between encodeURI and encodeURIComponent is that ;/?:@&=+$,# are not escaped in encodeURI (ECMA Docs).

On this project encodeURI is not good, as it does not escape characters that could be in file/dir names and S3 does not understand them when they're not escaped.

On the other hand encodeURIComponent is encoding / as well, which works but does not look good when copying the URL of a file.

This PR fixes the issues in these functions by creating a new function encodePath, giving the best of two functions utilizing encodeURI and encoding the missing characters that encodeURIComponent escapes compared to encodeURI.

qoomon commented 1 year ago

@korhox thx