Spaces in asset names

11 views
Skip to first unread message

David S Taylor

unread,
Mar 1, 2016, 7:29:01 PM3/1/16
to actionHero.js
Does Action Hero support spaces in asset names:


AH Returns:

Sorry, that file is not found :(

But if I rename the file without spaces, AH retrieves the file

Evan Tahler

unread,
Mar 1, 2016, 7:49:54 PM3/1/16
to actionHero.js
Nope!
I *think* that a URL with a space (either a literal " " or HTML encoded "%20") is technically out of spec.  Most OS/Browsers support it via convention, but I don't think that it's "legal".  
Supporting this would be fairly simple... the web server should HTML-decode the file name (here: https://github.com/evantahler/actionhero/blob/master/servers/web.js#L444).  Send in a pull request with a matching test! 

David S Taylor

unread,
Mar 1, 2016, 8:44:59 PM3/1/16
to actionHero.js
When I run a node server with my angular project it works fine. When I tried combining the two projects and having actionHero serve up my assets, I hit this problem.

This seems to work for me in a little test:

var decoded =  decodeURIComponent("assets/images/dashboard/panic%20button+test.jpg").replace(/\++/g, ' ');

so at line 449 of actionhero/server/web.js, we could add:

connection.params.file =  decodeURIComponent(connection.params.file).replace(/\++/g, ' ');

I tested a local change to web.xml and it works for me.

You seem kinda -1 on this so Im not sure you really want it in the project. Your call. I can also easily find all assets with spaces and rename them (without spaces) too


On Tuesday, March 1, 2016 at 4:29:01 PM UTC-8, David S Taylor wrote:

David S Taylor

unread,
Mar 1, 2016, 8:47:06 PM3/1/16
to actionHero.js
I tested a local change to web.xml and it works for me.

meant to say web.js 

On Tuesday, March 1, 2016 at 4:29:01 PM UTC-8, David S Taylor wrote:

Evan Tahler

unread,
Mar 1, 2016, 10:08:53 PM3/1/16
to actionHero.js
I would suggest sending in the Pull Request and letting the community discuss it! 

David S Taylor

unread,
Mar 1, 2016, 10:52:10 PM3/1/16
to actionHero.js
Pull request created. I hope you received it. And I added two tests. Let me know what else you need...

David S Taylor

unread,
Mar 1, 2016, 11:28:13 PM3/1/16
to actionHero.js
Reply all
Reply to author
Forward
0 new messages