remix icon indicating copy to clipboard operation
remix copied to clipboard

Redirects when multiple slashes

Open ErimTuzcuoglu opened this issue 2 years ago • 9 comments

Closes: #4422

  • [ ] Docs
  • [x] Tests

Testing Strategy: New and existing tests pass. We can try slashed routes manually.

ErimTuzcuoglu avatar Nov 16 '22 21:11 ErimTuzcuoglu

⚠️ No Changeset found

Latest commit: 69e84ce028e8d777bb6d763edad63b9f57ec9fe8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Nov 16 '22 21:11 changeset-bot[bot]

Hi @ErimTuzcuoglu,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].

Thanks!

- The Remix team

remix-cla-bot[bot] avatar Nov 16 '22 21:11 remix-cla-bot[bot]

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

remix-cla-bot[bot] avatar Nov 16 '22 21:11 remix-cla-bot[bot]

Is this something we need to consider for servers/runtimes other than express?

brophdawg11 avatar Nov 17 '22 16:11 brophdawg11

@brophdawg11 No, its just express specific.

ErimTuzcuoglu avatar Nov 18 '22 09:11 ErimTuzcuoglu

@ErimTuzcuoglu I didn't dig too deep, but was able to reproduce this using the Architect template as well? I'm wondering this is something that should be handled in a more central location, or at least should this logic go into each of the adapters. I will probably defer to one of the Remix team members here with more experience in the alternative runtimes. @jacob-ebey @mcansh?

brophdawg11 avatar Nov 18 '22 14:11 brophdawg11

I'm wondering this is something that should be handled in a more central location

i just tried a github url and it resolved with the multiple slashes without redirecting - perhaps we follow suit and normalize while matching?

however, vercel.com does normalize and redirect, while netlify.com will 404

I didn't dig too deep, but was able to reproduce this using the Architect template as well

same with Cloudflare Pages template, but that appears to throw at the miniflare level?

[pages:err] Unhandled Promise Rejection: TypeError: Invalid URL
    at new NodeError (node:internal/errors:393:5)
    at URL.onParseError (node:internal/url:565:9)
    at new URL (node:internal/url:645:5)
    at convertNodeRequest (/Users/logan/pages-slash-test/node_modules/.pnpm/@[email protected]/node_modules/@miniflare/http-server/src/index.ts:61:15)
    at Server.<anonymous> (/Users/logan/pages-slash-test/node_modules/.pnpm/@[email protected]/node_modules/@miniflare/http-server/src/index.ts:266:36)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

mcansh avatar Nov 18 '22 15:11 mcansh

The main problem is actually on URL constructor. It doesn't accept multiple slashes as a url and throws error. So when we removed slashes it works correctly, but for redirection I think we must make different implementations on adapters. As @mcansh said, on vercel we don't need any changes. But if we need I can check also other adapters and fix them too.

image

ErimTuzcuoglu avatar Nov 18 '22 20:11 ErimTuzcuoglu

The main problem is actually on URL constructor. It doesn't accept multiple slashes as a url and throws error. So when we removed slashes it works correctly, but for redirection I think we must make different implementations on adapters. As @mcansh said, on vercel we don't need any changes. But if we need I can check also other adapters and fix them too.

image

whats interesting is that new URL("https://github.com///") seems to be fine image

mcansh avatar Nov 18 '22 21:11 mcansh

Closing in favor of https://github.com/remix-run/remix/pull/5336

brophdawg11 avatar Jan 31 '23 21:01 brophdawg11