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

Centralize route matching in one place #2021

Open
wants to merge 1 commit into
base: v1.x-2022-07
Choose a base branch
from

Conversation

frandiox
Copy link
Contributor

Description

This PR extracts some refactoring I did in #1933 .

So far, we were matching routes for API and, if no matched API route was found, we ran again similar logic to match Server Components. The matching process is basically iterating over every route, converting string keys to regular expressions and testing them until we find a route match.

With the changes proposed here, we only run the matching logic once at the beginning and store the result for later. It should reduce code size and CPU a little but, more importantly, it centralizes the route matching in one place so that we can implement plugins later.


Before submitting the PR, please make sure you do the following:

  • Read the Contributing Guidelines
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123)
  • Update docs in this repository according to your change
  • Run yarn changeset add if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning

@frandiox frandiox requested review from blittle, wizardlyhel and a team August 22, 2022 13:49
@github-actions
Copy link
Contributor

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset.
If the changes are user-facing and should cause a version bump, run "yarn changeset add" to track your changes and include them in the next release CHANGELOG.
If you are making simple updates to examples or documentation, you do not need to add a changeset.

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.

1 participant