You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise): Community
is this issue currently blocking your project? (yes/no): No
is this issue affecting a production system? (yes/no): Yes
Context
node version: 12.18.2
module version with issue: "@hapi/hapi": "^19.1.1", "@hapi/inert": "^6.0.1"
last module version without issue: IDK
environment (e.g. node, browser, native): node
used with (e.g. hapi application, another framework, standalone, ...): hapi application
any other relevant information:
What are you trying to achieve or the steps to reproduce?
I'm defining a custom endpoint named /docs/js which would serve any file in the existent /docs/js directory located at the root path of my project, this is the output of my JSDoc automation routine, so an index.html is served from there and inner CSS/JS should be loaded upon the rendering of that index.
Similarly, I want to do the same to swagger and test coverage, so I would just replicate the same pattern.
Everything works fine, except the redirectToSlash functionality, I did some digging through the plugin source code and if I remove this snippet demonstrated below, the functionality works as expected.
When I access localhost:port/docs/js I got the index.html and extra css/js can't be loaded.
When I access localhost:port/docs/js/ I got the index.html and all extra css/js works smoothly.
When I access localhost:port/docs/js the requests are not redirected to localhost:port/docs/js/
What result did you expect?
Access localhost:port/docs/js and be redirected to localhost:port/docs/js/ since the redirectToSlash option is set to true.
PS: I validated that:
That handler is being executed
No other handler is messing with this one
If I manually insert the / at the end, it works fine
I did some debugging in the directory.js code and if I remove/comment the snippet mentioned above, the slash is appended to the URL as expected.
No change was made to stripTrailingSlash configuration, the defaults are in place
I performed some console.log instructions and here is what I got
inert/lib/directory.js line 123
if(internals.isDirectory(error)){console.log(resource);console.log(settings);console.log(request.server.settings.router.stripTrailingSlash);console.log(hasTrailingSlash);// more code below}
Finally, even though the console.log is showing /docs/js/, the request in the browser (and also using curl) is not being redirected as expected, as demonstrated below.
The text was updated successfully, but these errors were encountered:
I have a suspicion that this may have the same root cause as #145. The reason I'm thinking that is path.resolve() removes trailing slashes, whereas path.join() does not. The path joining was removed in 4514a5e.
Support plan
Context
"@hapi/hapi": "^19.1.1"
,"@hapi/inert": "^6.0.1"
What are you trying to achieve or the steps to reproduce?
I'm defining a custom endpoint named
/docs/js
which would serve any file in the existent/docs/js
directory located at the root path of my project, this is the output of my JSDoc automation routine, so an index.html is served from there and inner CSS/JS should be loaded upon the rendering of that index.Similarly, I want to do the same to
swagger
andtest coverage
, so I would just replicate the same pattern.Everything works fine, except the
redirectToSlash
functionality, I did some digging through the plugin source code and if I remove this snippet demonstrated below, the functionality works as expected.What was the result you got?
localhost:port/docs/js
I got the index.html and extra css/js can't be loaded.localhost:port/docs/js/
I got the index.html and all extra css/js works smoothly.localhost:port/docs/js
the requests are not redirected tolocalhost:port/docs/js/
What result did you expect?
localhost:port/docs/js
and be redirected tolocalhost:port/docs/js/
since theredirectToSlash
option is set to true.PS: I validated that:
/
at the end, it works finedirectory.js
code and if I remove/comment the snippet mentioned above, the slash is appended to the URL as expected.stripTrailingSlash
configuration, the defaults are in place/docs/js/
, the request in the browser (and also using curl) is not being redirected as expected, as demonstrated below.The text was updated successfully, but these errors were encountered: