Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Je issue/164 #169

Closed
wants to merge 3 commits into from
Closed

[Je issue/164 #169

wants to merge 3 commits into from

Conversation

4141done
Copy link
Collaborator

@4141done 4141done commented Aug 18, 2023

What

This PR presents some additional ideas to be considered for addition to #167 aiming to fix issue #164

Expectations

This solution assumes that the following configuration options are set to true

  • APPEND_SLASH_FOR_POSSIBLE_DIRECTORY
  • PROVIDE_INDEX_PAGE
  • ALLOW_DIRECTORY_LIST

Given a folder test with an index.html present in the directory, the index.html should be served for:

  • /test
  • /test/
  • /test?foo=bar
  • /test/?foo=bar

Given a folder test WITHOUT an index.html present in the directory, files in the directory should be listed for:

  • /test
  • /test/
  • /test?foo=bar
  • /test/?foo=bar

Notes

  • The @trailslash was rewriting to $request_uri with a trailing slash on the end. In the case of /test?foo=bar we'd wind up with /test?foo=bar/ which when combined with the other changes led to a rewrite loop
  • Changed the check for directory or file to consider the path without anchor or querystring
  • I added yet another integration test suite and shuffled around the conditionals that maybe make the tests even more confusing - but do cover this case.

if (len < 1) {
return false;
}
if (!path) return false;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotation:
Not a big deal, but the previous implementation didn't account for null. Perhaps that was on purpose? Either way, if we assume null, undefined, or "" are all "not a directory" this function gets a lot simpler.

@@ -326,7 +326,7 @@ server {

location @trailslash {
# 302 to request without slashes
rewrite ^ $scheme://$http_host$request_uri/ redirect;
rewrite ^ $scheme://$http_host$uri/$is_args$query_string redirect;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotation:
Insert the trailing slash after the path and preserve the query string after it.

@4141done
Copy link
Collaborator Author

Closing in favor of #167

@4141done 4141done closed this Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants