From 57ecf196681964fece2bf9e1d11e4f88e78182f3 Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Thu, 1 Feb 2024 17:10:14 +0800 Subject: [PATCH] fix: compatible when undefined basename (#6780) --- packages/runtime/CHANGELOG.md | 4 ++++ packages/runtime/package.json | 2 +- packages/runtime/src/singleRouter.tsx | 3 +-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/runtime/CHANGELOG.md b/packages/runtime/CHANGELOG.md index e8770383ea..5243f5a572 100644 --- a/packages/runtime/CHANGELOG.md +++ b/packages/runtime/CHANGELOG.md @@ -1,5 +1,9 @@ # @ice/runtime +## 1.4.1 + +- fix: compatible with basename is undefined. + ## 1.4.0 ### Minor Changes diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 69940a6576..9252da021f 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@ice/runtime", - "version": "1.4.0", + "version": "1.4.1", "description": "Runtime module for ice.js", "type": "module", "types": "./esm/index.d.ts", diff --git a/packages/runtime/src/singleRouter.tsx b/packages/runtime/src/singleRouter.tsx index d51346c4d7..312d82e01d 100644 --- a/packages/runtime/src/singleRouter.tsx +++ b/packages/runtime/src/singleRouter.tsx @@ -24,7 +24,6 @@ RouteContext.displayName = 'RouteContext'; export function useData(): T { const value = React.useContext(RouteContext); - console.log('use value', value); return value.routeData?.data; } @@ -259,7 +258,7 @@ export const matchRoutes = ( basename: string, ) => { const pathname = typeof location === 'string' ? location : location.pathname; - const stripedPathname = stripBasename(pathname || '/', basename); + const stripedPathname = stripBasename(pathname || '/', basename || '/'); let branches = flattenRoutes(routes); if (branches.length === 1) { // Just one branch, no need to match.