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

Fix adapter request creation when double slashes exist #5336

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

brophdawg11
Copy link
Contributor

The root cause of this came down to us passing the origin in the optional second base param for the new URL() constructor. When we did this, an incoming pathname of // got incorrectly identified as a protocol-less absolute URL. Since we know the origin, we can just pass an absolute URL directly into the first param to avoid this:

let origin = 'http://localhost';
let path = '//';

// ❌ Throws `Invalid URL` error
new URL(path, origin);

// ✅ All good in the hood
new URL(`${origin}${path}`);

Closes: #4422
Replace #4622

  • Docs
  • Tests

Testing Strategy:

  • Unit tests for each of the adapters
  • Manual testing for express

⚠️ Note this does not change anything about our route matching logic, it just lets the request make it through to matching. Current behavior is as follows:

  • // will match a root/index route
  • //todos will 404 if a /todos route exists

@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2023

🦋 Changeset detected

Latest commit: 7bb4fbe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@remix-run/architect Patch
@remix-run/express Patch
@remix-run/netlify Patch
@remix-run/vercel Patch
@remix-run/serve Patch
@remix-run/dev Patch
create-remix Patch
remix Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/node Patch
@remix-run/react Patch
@remix-run/server-runtime Patch
@remix-run/testing Patch

Not sure what this means? Click here to learn what changesets are.

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

@brophdawg11 brophdawg11 merged commit 611c68b into dev Feb 1, 2023
@brophdawg11 brophdawg11 deleted the brophdawg11/double-slashes-invalid-url branch February 1, 2023 15:09
@github-actions github-actions bot added the awaiting release This issue has been fixed and will be released soon label Feb 1, 2023
mcansh added a commit to mcansh/remix-fastify that referenced this pull request Feb 1, 2023
@see: remix-run/remix#5336

Signed-off-by: Logan McAnsh <logan@mcan.sh>
mcansh added a commit to mcansh/remix-fastify that referenced this pull request Feb 1, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2023

🤖 Hello there,

We just published version v0.0.0-nightly-7f3c92b-20230202 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release This issue has been fixed and will be released soon CLA Signed
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
2 participants