Add encodeFilePath to FileUtils to convert file paths into encoded strings (replace metacharacters such as %, @, $, #, etc.)#9190
Conversation
|
It's possible that this will also be fixed by the Project Manager Revamp (#9015) |
|
@Mark-Simulacrum Yes, this should be in a reusable function in |
|
Well, in Chrome 37, |
|
In #9117, |
|
Oops, didn't think about that. So those are the chars |
|
Ready for another review. |
|
@Mark-Simulacrum Can you add some unit tests to this? |
|
Sure - they should go in |
|
Yep! |
There was a problem hiding this comment.
Should we be replacing / with %2F? Since this is not a valid symbol in a file name (directory separator), perhaps this should not be replaced?
|
Is it standard Brackets policy to squash commits? I currently have 6 in this branch, should I squash them (not now, but when final review is completed)? |
|
We don't require them to be squashed, but you can do it, if you like. I'm fine with not having them squashed. |
|
I don't like squashing commits myself - since it effectively erases history. |
|
@Mark-Simulacrum Remind me -- why do we need a custom utility for this instead of just using the built-in |
|
@peterflynn We don't want to replace |
|
@marcelgerber @peterflynn Perhaps the correct fix for that would be to use |
|
@Mark-Simulacrum I think what you need is only |
|
@RaymondLim Okay. I've implemented the suggested change in 592febc, and merged with master. Ready for another review. |
There was a problem hiding this comment.
You could use encodedPath = pathArray.map(...) instead.
That would actually make the line above unnecessary.
There was a problem hiding this comment.
Should I use LoDash _.map or native map?
There was a problem hiding this comment.
I think that using LoDash _.map is preferable, due to the speed increase, since this is a utility method that may be called quite often.
|
Committed test changes and fixed my mistake with |
There was a problem hiding this comment.
It's more canonical to use native pathArray.map(...) here. We usually only use the Lodash versions when traversing Object key-value pairs instead of Arrays.
There was a problem hiding this comment.
And once that's fixed I think you'll need to remove the import above too, else JSHint will complain about the unused var
|
Also: It would be good to put up a squashed version of the PR at this point, since 12 commits is a lot for a relatively small change like this. |
05c4982 to
73ff6c8
Compare
|
Didn't see the point of making a new PR -- I've rebased onto master here. |
|
Thanks! |
c0797d8 to
73ff6c8
Compare
Use this function to properly set the source of images in ImageViewer.
73ff6c8 to
afb2309
Compare
|
Fixed merge conflict, squashed. |
|
LGTM. Merging. |
Add encodeFilePath to FileUtils to convert file paths into encoded strings (replace metacharacters such as %, @, $, #, etc.)
Cannot use encodeURI/encodeURIComponent because they replace
#with%25, which is incorrect - should be replaced by%23.I'm not sure if there is a Brackets' utility for this already (I searched for it but couldn't find it).
I've tested with
test#tt.jpgandtest%tt.jpg, but nothing else - are there any other special characters that should be added to this replace scheme?Should this be moved to a module in
utils/and loaded from ImageViewer?Fixes #9117.