-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying/retaining names of downloaded files. #488
Conversation
fileName = window.atob(fileNameBase64); | ||
} | ||
} catch (err) { | ||
// Filename wasn't base64-encoded so let's ignore it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to base64 encode the filename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is not encoded/escaped and contains a :
, using :
as a separator would not work correctly. Base64-encoding seemed like the easiest option that is guaranteed to work, but there are certainly other options that would work too!
src/client/wetty/download.ts
Outdated
// Filename wasn't base64-encoded so let's ignore it | ||
} | ||
|
||
if (typeof fileName !== "string") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im not a big fan of typeof checks as it implies the type can change.
Given the type is string|undefined
could the check be is fileName === undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the PR some question and nitpicks
This allows the name of downloaded files to be specified by prepending
base64(filename):
to the file contents after a^[[5i
.It seems the implementation allows the file contents to not be base64 encoded, and in that case downloading a file containing a
:
would break with these changes. In other cases, such as when using the documented bash function, this should be backwards compatible.