This test is to make sure URLs are not double-encoded when a redirect is thrown with `merge_slash = True`
(path, expected)
| 137 | [("/merge/%//path", "/merge/%25/path"), ("/merge//st/path", "/merge/st/path")], |
| 138 | ) |
| 139 | def test_merge_slash_encoding(path, expected): |
| 140 | """This test is to make sure URLs are not double-encoded |
| 141 | when a redirect is thrown with `merge_slash = True`""" |
| 142 | url_map = r.Map( |
| 143 | [ |
| 144 | r.Rule("/merge/<some>/path"), |
| 145 | ] |
| 146 | ) |
| 147 | adapter = url_map.bind("localhost", "/") |
| 148 | |
| 149 | with pytest.raises(r.RequestRedirect) as excinfo: |
| 150 | adapter.match(path) |
| 151 | |
| 152 | assert excinfo.value.new_url.endswith(expected) |
| 153 | |
| 154 | |
| 155 | def test_merge_slashes_build(): |