Skip to content

HttpRouter.mountApp prefix matching fixed #5111

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mlegenhausen
Copy link
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Example router

HttpRouter.empty.pipe(
  HttpRouter.mountApp('/a', HttpServerResponse.text('OK')),
  HttpRouter.get('/ab', HttpServerResponse.text('Unreachable'))
)

the first mounted app matches everything that starts with /a which is unexpected as you would expect that it only matches on exactly /a or /a/*. It even get's more confusion if you explicitly add trailing slash to the mount.

My PR tries to fix that issue by doing the bare minimum. It might make sense to also add support for something like /a* if you want to match prefixes.

@mlegenhausen mlegenhausen requested a review from tim-smart as a code owner June 27, 2025 14:14
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Jun 27, 2025
Copy link

changeset-bot bot commented Jun 27, 2025

🦋 Changeset detected

Latest commit: 9cf7767

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

This PR includes changesets to release 28 packages
Name Type
@effect/platform Patch
@effect/cli Patch
@effect/cluster Patch
@effect/experimental Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/rpc Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-drizzle Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-node Patch
@effect/sql Patch
@effect/workflow Patch
@effect/ai Patch
@effect/ai-anthropic Patch
@effect/ai-openai Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/sql-kysely 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Discussion Ongoing
Development

Successfully merging this pull request may close these issues.

1 participant