[PR #322] [MERGED] refactor(routing): extract shared compareRoutes comparator to utils #476

Closed
opened 2026-05-06 13:08:17 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/322
Author: @james-elicx
Created: 3/7/2026
Status: Merged
Merged: 3/7/2026
Merged by: @james-elicx

Base: mainHead: refactor/shared-route-sort-comparator


📝 Commits (1)

  • 1b8beb1 refactor(routing): extract shared compareRoutes comparator to utils

📊 Changes

3 files changed (+16 additions, -14 deletions)

View changed files

📝 packages/vinext/src/routing/app-router.ts (+2 -5)
📝 packages/vinext/src/routing/pages-router.ts (+3 -9)
📝 packages/vinext/src/routing/utils.ts (+11 -0)

📄 Description

Summary

  • Extracts the duplicated sort comparator into a new compareRoutes<T extends { pattern: string }>() function in routing/utils.ts, which already exports routePrecedence
  • Replaces three identical inline comparators: scanPageRoutes and scanApiRoutes in pages-router.ts, and appRouter in app-router.ts
  • No behaviour change — only deduplication

Testing

pnpm test tests/routing.test.ts tests/route-sorting.test.ts — 75 tests pass.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/322 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/7/2026 **Status:** ✅ Merged **Merged:** 3/7/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `refactor/shared-route-sort-comparator` --- ### 📝 Commits (1) - [`1b8beb1`](https://github.com/cloudflare/vinext/commit/1b8beb11e5acb11e3d5757b96fdc1f8bcce7e582) refactor(routing): extract shared compareRoutes comparator to utils ### 📊 Changes **3 files changed** (+16 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/routing/app-router.ts` (+2 -5) 📝 `packages/vinext/src/routing/pages-router.ts` (+3 -9) 📝 `packages/vinext/src/routing/utils.ts` (+11 -0) </details> ### 📄 Description ## Summary - Extracts the duplicated sort comparator into a new `compareRoutes<T extends { pattern: string }>()` function in `routing/utils.ts`, which already exports `routePrecedence` - Replaces three identical inline comparators: `scanPageRoutes` and `scanApiRoutes` in `pages-router.ts`, and `appRouter` in `app-router.ts` - No behaviour change — only deduplication ## Testing `pnpm test tests/routing.test.ts tests/route-sorting.test.ts` — 75 tests pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:17 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#476
No description provided.