Skip to content

fix!: removes @fastify/express support#29

Merged
chenjiahan merged 3 commits intomainfrom
fix_original_url_0316
Mar 16, 2026
Merged

fix!: removes @fastify/express support#29
chenjiahan merged 3 commits intomainfrom
fix_original_url_0316

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Mar 16, 2026

Our Fastify integration relied on @fastify/express, so it was more of a compatibility path than first-class support. Over time, keeping that path adds extra framework-specific logic and maintenance overhead to a package that is primarily designed as an express-style middleware.

Removing it helps keep the implementation focused and simpler to maintain.

Copilot AI review requested due to automatic review settings March 16, 2026 01:05
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the logic for selecting the appropriate request URL, particularly when dealing with frameworks or middleware that might modify req.url or provide an originalUrl. By introducing a dedicated helper and updating the URL retrieval function, it ensures that the most accurate URL is consistently used, preventing issues with URI encoding and rewritten requests. The changes are supported by new tests and a cleanup of type definitions.

Highlights

  • Improved URL Selection Logic: Introduced a new helper function, shouldUseOriginalURL, to accurately determine when to prefer req.originalUrl over req.url, specifically addressing scenarios where middleware has rewritten the request URL.
  • Enhanced getRequestURL Functionality: Updated the getRequestURL function to leverage the new shouldUseOriginalURL helper, ensuring correct URL resolution in various request rewriting situations, such as those involving Fastify's URI decoding behavior.
  • Comprehensive Test Coverage: Added a new test file with dedicated test cases for getRequestURL to validate its behavior under different conditions, including when getURL is present, when originalUrl is an encoded version of req.url, and when middleware has rewritten req.url.
  • Type Definition Refactoring: Relocated several type definitions (IncomingMessage, ServerResponse, ExpectedIncomingMessage, ExpectedServerResponse, etc.) from types/utils/compatibleAPI.d.ts to a more central location, improving type management and organization.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/utils/compatibleAPI.js
    • Added shouldUseOriginalURL helper function to determine if req.originalUrl should be used.
    • Modified getRequestURL to conditionally use req.originalUrl based on the new shouldUseOriginalURL logic.
  • test/utils/compatibleAPI.test.js
    • Added new test file for getRequestURL function.
    • Included test cases for getURL preference, originalUrl encoding preference, and middleware rewritten req.url scenarios.
  • types/utils/compatibleAPI.d.ts
    • Removed several JSDoc @typedef definitions, indicating their relocation to a central type file.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves URL selection logic by introducing a shouldUseOriginalURL helper to handle cases where middleware rewrites req.url. The change is well-tested and also includes a cleanup of type definitions. My only suggestion is to improve error handling in the new helper function by documenting why an error is being ignored.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c50b62ddf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves getRequestURL behavior to better distinguish between framework-provided “original URL” fields (e.g., Fastify’s originalUrl) and cases where middleware has rewritten req.url, ensuring downstream filename resolution uses the correct URL form.

Changes:

  • Added a shouldUseOriginalURL helper to only prefer req.originalUrl when it matches the encoded form of req.url.
  • Updated getRequestURL to use this helper rather than always preferring originalUrl when present.
  • Refactored/moved compatible API type definitions in the generated types output and added targeted unit tests for the URL selection behavior.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
src/utils/compatibleAPI.js Introduces shouldUseOriginalURL and updates getRequestURL selection logic for rewritten vs. decoded URLs.
test/utils/compatibleAPI.test.js Adds unit tests covering getURL override, encoded originalUrl preference, and rewrite scenarios.
types/utils/compatibleAPI.d.ts Updates the declarations to reflect the reorganized type definitions for this utility module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chenjiahan chenjiahan changed the title fix: improve URL selection logic for rewritten requests fix!: removes @fastify/express support Mar 16, 2026
@chenjiahan chenjiahan merged commit ce1f7ef into main Mar 16, 2026
5 checks passed
@chenjiahan chenjiahan deleted the fix_original_url_0316 branch March 16, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants