diff --git a/packages/router-core/src/rewrite.ts b/packages/router-core/src/rewrite.ts
index 0da50c5b62..5c82408c00 100644
--- a/packages/router-core/src/rewrite.ts
+++ b/packages/router-core/src/rewrite.ts
@@ -1,7 +1,6 @@
 import { joinPaths, trimPath } from './path'
 import type { LocationRewrite } from './router'
 
-/** Compose multiple rewrite pairs into a single in/out rewrite. */
 /** Compose multiple rewrite pairs into a single in/out rewrite. */
 export function composeRewrites(rewrites: Array<LocationRewrite>) {
   return {
@@ -20,7 +19,6 @@ export function composeRewrites(rewrites: Array<LocationRewrite>) {
   } satisfies LocationRewrite
 }
 
-/** Create a rewrite pair that strips/adds a basepath on input/output. */
 /** Create a rewrite pair that strips/adds a basepath on input/output. */
 export function rewriteBasepath(opts: {
   basepath: string
@@ -28,13 +26,10 @@ export function rewriteBasepath(opts: {
 }) {
   const trimmedBasepath = trimPath(opts.basepath)
   const normalizedBasepath = `/${trimmedBasepath}`
-  const normalizedBasepathWithSlash = `${normalizedBasepath}/`
   const checkBasepath = opts.caseSensitive
     ? normalizedBasepath
     : normalizedBasepath.toLowerCase()
-  const checkBasepathWithSlash = opts.caseSensitive
-    ? normalizedBasepathWithSlash
-    : normalizedBasepathWithSlash.toLowerCase()
+  const checkBasepathWithSlash = `${checkBasepath}/`
 
   return {
     input: ({ url }) => {
@@ -58,7 +53,6 @@ export function rewriteBasepath(opts: {
   } satisfies LocationRewrite
 }
 
-/** Execute a location input rewrite if provided. */
 /** Execute a location input rewrite if provided. */
 export function executeRewriteInput(
   rewrite: LocationRewrite | undefined,
@@ -75,7 +69,6 @@ export function executeRewriteInput(
   return url
 }
 
-/** Execute a location output rewrite if provided. */
 /** Execute a location output rewrite if provided. */
 export function executeRewriteOutput(
   rewrite: LocationRewrite | undefined,
diff --git a/packages/router-core/tests/rewrite.test.ts b/packages/router-core/tests/rewrite.test.ts
new file mode 100644
index 0000000000..c5ca2e9428
--- /dev/null
+++ b/packages/router-core/tests/rewrite.test.ts
@@ -0,0 +1,72 @@
+import { describe, expect, test } from 'vitest'
+import {
+  composeRewrites,
+  executeRewriteInput,
+  executeRewriteOutput,
+  rewriteBasepath,
+} from '../src/rewrite'
+import type { LocationRewrite } from '../src'
+
+describe('rewrite helpers', () => {
+  test('basepath rewrite strips input and restores output', () => {
+    const rewrite = rewriteBasepath({ basepath: '/app/' })
+    const inputUrl = new URL('https://example.com/app/posts')
+
+    expect(executeRewriteInput(rewrite, inputUrl).pathname).toBe('/posts')
+
+    const outputUrl = new URL('https://example.com/posts')
+    expect(executeRewriteOutput(rewrite, outputUrl).pathname).toBe('/app/posts')
+  })
+
+  test('basepath rewrite handles root output', () => {
+    const rewrite = rewriteBasepath({ basepath: '/app' })
+    const url = new URL('https://example.com/')
+
+    expect(executeRewriteOutput(rewrite, url).pathname).toBe('/app/')
+  })
+
+  test('case-insensitive basepath input preserves original suffix casing', () => {
+    const rewrite = rewriteBasepath({ basepath: '/App' })
+    const url = new URL('https://example.com/app/Users')
+
+    expect(executeRewriteInput(rewrite, url).pathname).toBe('/Users')
+  })
+
+  test('composeRewrites applies input forward and output backward', () => {
+    const calls: Array<string> = []
+    const first: LocationRewrite = {
+      input: ({ url }) => {
+        calls.push('first-in')
+        url.pathname += 'a'
+        return url
+      },
+      output: ({ url }) => {
+        calls.push('first-out')
+        url.pathname += 'd'
+        return url
+      },
+    }
+    const second: LocationRewrite = {
+      input: ({ url }) => {
+        calls.push('second-in')
+        url.pathname += 'b'
+        return url
+      },
+      output: ({ url }) => {
+        calls.push('second-out')
+        url.pathname += 'c'
+        return url
+      },
+    }
+
+    const rewrite = composeRewrites([first, second])
+
+    expect(
+      executeRewriteInput(rewrite, new URL('https://example.com/')).pathname,
+    ).toBe('/ab')
+    expect(
+      executeRewriteOutput(rewrite, new URL('https://example.com/')).pathname,
+    ).toBe('/cd')
+    expect(calls).toEqual(['first-in', 'second-in', 'second-out', 'first-out'])
+  })
+})
