Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix empty SCRIPT_NAME with partial match route bug
Why you made the change: I made this change so that SCRIPT_NAME and PATH_INFO would be set appropriately in the scenario where a partial match route is used. How the change addresses the need: There is an issue with the current version of rewrite_partial_path_info in HttpRouter where it does not set SCRIPT_NAME appropriately. When the request environments PATH_INFO is set, it causes the request.rack_request.path_info helper return the updated version, not the original. This is requst.rack_request.path_info eventually just reads the PATH_INFO value out of the request environment. As a side effect of this, the original code would always set the SCRIPT_NAME to "" because it would be slicing from request.rack_request.path_info[0, 0] in actuality. This change resolves this issue by first temporarily storing a dup of the original path_info and using that to determine the end index for the SCRIPT_NAME. This change also handles setting SCRIPT_NAME correctly for the somewhat unique but common case of matching the partial match exactly. This change also includes a fix to handle maintaining URI encoded values in PATH_INFO and SCRIPT_INFO. Currently, there is a problem where because the method uses the request.path helper HttpRouter provides, which URI.decodes the string, it screws up both the PATH_INFO and SCRIPT_NAME. Therefore, I URI.encode it back appropriately before any offsetting, or setting is done. I have also added tests for each of these cases as I couldn't find any tests covering this before. This fixes issue #87.
- Loading branch information