I have developed a file system where I start with one folder and I display folders and files recursively as the user clicks on them.
I have no issue traversing where there is no white space between file names, but as soon as I enter a name with white space, I receive an error. Example:
Home
.My Documents
.Downloads
.Desktop
the Error I receive by the fs is
REQUEST ./Home/My%20Documents
{ Error: ENOENT: no such file or directory, scandir './Home/My%20Documents'
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: './Home/My%20Documents' }
I tried to look it up, but can anyone give me a hint about how to get through this?
content.hbs
{{#each contents}}
<tr>
{{#if isFolder}}
<td>
<a href="/{{name}}">
<div><img style="vertical-align:middle" src="folder.png" height="32" width="32" > <span style="margin-left: 20px">{{name}}</span></div></a> </td>
<td></td>
<td></td>
{{else}}
<td><div><img style="vertical-align:middle" src="file.png" height="32" width="32" > <span style="margin-left: 20px">{{name}}</span></div> </td>
<td>{{size}} Mb</td>
<td></td>
{{/if}}
</tr>
{{/each}}
I have developed a file system where I start with one folder and I display folders and files recursively as the user clicks on them.
I have no issue traversing where there is no white space between file names, but as soon as I enter a name with white space, I receive an error. Example:
Home
.My Documents
.Downloads
.Desktop
the Error I receive by the fs is
REQUEST ./Home/My%20Documents
{ Error: ENOENT: no such file or directory, scandir './Home/My%20Documents'
errno: -2,
code: 'ENOENT',
syscall: 'scandir',
path: './Home/My%20Documents' }
I tried to look it up, but can anyone give me a hint about how to get through this?
content.hbs
{{#each contents}}
<tr>
{{#if isFolder}}
<td>
<a href="/{{name}}">
<div><img style="vertical-align:middle" src="folder.png" height="32" width="32" > <span style="margin-left: 20px">{{name}}</span></div></a> </td>
<td></td>
<td></td>
{{else}}
<td><div><img style="vertical-align:middle" src="file.png" height="32" width="32" > <span style="margin-left: 20px">{{name}}</span></div> </td>
<td>{{size}} Mb</td>
<td></td>
{{/if}}
</tr>
{{/each}}
Share
edited Mar 20, 2018 at 23:45
Sagar
asked Mar 20, 2018 at 23:08
SagarSagar
4167 silver badges26 bronze badges
1 Answer
Reset to default 7It seems that you are receiving the path from a query string. Once it is clearly encoded you will have to do path = decodeURIComponent(path)
.