Skip to content

Commit

Permalink
fix: shoud not overrides cache when request has tail slash (#6649)
Browse files Browse the repository at this point in the history
  • Loading branch information
zllkjc authored Dec 20, 2024
1 parent 6d71554 commit 95b026d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/purple-parrots-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/server-core': patch
---

fix: cache should not be overrides when request has tail slash
fix: 当请求有尾斜杠时,缓存不应该被重写
3 changes: 2 additions & 1 deletion packages/server/core/src/plugins/render/ssrCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
CacheOptionProvider,
Container,
} from '@modern-js/types';
import { removeTailSlash } from '@modern-js/utils';
import { X_RENDER_CACHE } from '../../constants';
import type {
RequestHandler,
Expand Down Expand Up @@ -120,7 +121,7 @@ function computedKey(req: Request, cacheControl: CacheControl): string {
// examples:
// pathname1: '/api', pathname2: '/api/'
// pathname1 as same as pathname2
const defaultKey = pathname.replace(/.+\/+$/, '');
const defaultKey = pathname === '/' ? pathname : removeTailSlash(pathname);

if (customKey) {
if (typeof customKey === 'string') {
Expand Down

0 comments on commit 95b026d

Please sign in to comment.