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

Redirects when multiple slashes #4622

Conversation

ErimTuzcuoglu
Copy link

Closes: #4422

  • Docs
  • Tests

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

@changeset-bot
Copy link

changeset-bot bot commented Nov 16, 2022

⚠️ No Changeset found

Latest commit: 69e84ce

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

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Nov 16, 2022

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

@ErimTuzcuoglu ErimTuzcuoglu changed the base branch from main to dev November 16, 2022 21:15
@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Nov 16, 2022

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

@brophdawg11
Copy link
Contributor

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

@ErimTuzcuoglu
Copy link
Author

@brophdawg11 No, its just express specific.

Copy link
Collaborator

@machour machour left a comment

Choose a reason for hiding this comment

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

@ErimTuzcuoglu can you please fix the conflict in the contributors files? 🙏🏼
Protip: put your name in the right spot alphabetically, conflicts will be less likely to happen

@brophdawg11
Copy link
Contributor

@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?

@mcansh
Copy link
Collaborator

mcansh commented Nov 18, 2022

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)

@ErimTuzcuoglu
Copy link
Author

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

@mcansh
Copy link
Collaborator

mcansh commented Nov 18, 2022

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

Copy link
Collaborator

@machour machour left a comment

Choose a reason for hiding this comment

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

@ErimTuzcuoglu Please update other adapters as well and rebase this PR to latest dev 🙏🏼

@machour machour added needs-response We need a response from the original author about this issue/PR feat:routing labels Jan 22, 2023
@brophdawg11
Copy link
Contributor

Closing in favor of #5336

@machour machour removed the needs-response We need a response from the original author about this issue/PR label Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding // to the end of the root route throws an Internal Server Error
4 participants