Skip to content

Commit

Permalink
Add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Feb 17, 2023
1 parent 1c68bc0 commit 0255da7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/next/src/shared/lib/router/utils/app-paths.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ describe('normalizeRscPath', () => {
it('should normalize url with .rsc', () => {
expect(normalizeRscPath('/test.rsc', true)).toBe('/test')
})
it('should normalize url with .rsc and querystring', () => {
it('should normalize url with .rsc and searchparams', () => {
expect(normalizeRscPath('/test.rsc?abc=def', true)).toBe('/test?abc=def')
})
})
describe('disabled', () => {
it('should normalize url with .rsc', () => {
expect(normalizeRscPath('/test.rsc', false)).toBe('/test.rsc')
})
it('should normalize url with .rsc and querystring', () => {
it('should normalize url with .rsc and searchparams', () => {
expect(normalizeRscPath('/test.rsc?abc=def', false)).toBe(
'/test.rsc?abc=def'
)
Expand Down
4 changes: 4 additions & 0 deletions packages/next/src/shared/lib/router/utils/app-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ export function normalizeAppPath(route: string) {
)
}

/**
* Strips the `.rsc` extension if it's in the pathname.
* Since this function is used on full urls it checks `?` for searchParams handling.
*/
export function normalizeRscPath(pathname: string, enabled?: boolean) {
return enabled
? pathname.replace(
Expand Down

0 comments on commit 0255da7

Please sign in to comment.