Should directory listing be relative path?

28 views
Skip to first unread message

Brad Wood

unread,
Oct 26, 2022, 1:45:22 PM10/26/22
to Undertow Dev
Before I enter a ticket, I wanted to check here to see if I'm off base.  I've been playing around with using a resource handler to enable directory listing for a single folder.

So I wanted to test and see if I could use a predicate rule to specify a resource handler, basically like an alias (virtual directory).  FWIW, I normally use a custom ResourceManager to implement web aliases, but I wanted to try this out.

path-prefix(/foo)-> resource(location='C:/sandbox/mySite/bar/',allow-listing=true)

This sort of works, but the issue is when I hit 
it will not serve the file 
C:/sandbox/mySite/bar/test.txt
but instead tries to serve
C:/sandbox/mySite/bar/foo/test.txt
because "foo" is still part of the path.  

Ok, no problem.  So attempt number 2 where I swap out the request URI to be the "remaining" text.  More boilerplate, but works more like a virtual directory:

path-prefix(/foo)-> { set(attribute=%U,value=${remaining}); resource(location='C:/sandbox/mySite/bar/',allow-listing=true) }

This allows the URL above to serve the expected file, BUT when I hit
to get a directory listing of the folder, the links in the web page are broken as they point to `/test.txt` which is an absolute URI which doesn't not exist.  

It seems that a simple workaround for this would be to use a relative path in the HTML of the directory listing page.  Therefore, if I'm viewing the contents of /foo/ in my browser and I click on "test.txt", then the browser would navigate to /foo/test/txt without caring what the server side request URI looks like.  This would just require removing the path and the leading slash prior to the file name in the directory listing's HTML output.

Thoughts?

Brad Wood

unread,
Dec 23, 2022, 1:25:06 PM12/23/22
to Undertow Dev
Any feedback on this question?

Flavia Rainone

unread,
Dec 23, 2022, 11:43:16 PM12/23/22
to Undertow Dev
Hi Brad!

The same comment that I did for the other two apply to this one. Sorry I missed your messages!

I think it might be a bug, or just something that was not taken into account when the resource with allow-listing=true was implemented.

Please, create a Jira and mark it as a bug, with the reproduce steps, and we'll confirm if it is a bug and submit a fix.

Thanks!

Brad Wood

unread,
Dec 27, 2022, 2:58:44 PM12/27/22
to Undertow Dev
Reply all
Reply to author
Forward
0 new messages