This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-booster-ui.git
The following commit(s) were added to refs/heads/main by this push:
new 4e3b1bde Fix validation guard for router (#520)
4e3b1bde is described below
commit 4e3b1bdeae3c2dc5f6b6420b89264c8fd429110d
Author: Fine0830 <[email protected]>
AuthorDate: Thu Feb 5 18:01:05 2026 +0800
Fix validation guard for router (#520)
---
.github/workflows/nodejs.yml | 2 +-
src/router/__tests__/guards.spec.ts | 16 +++-------------
src/router/guards.ts | 4 +---
src/views/components/Pagination.vue | 4 +++-
4 files changed, 8 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml
index d9bfe635..6794b2db 100644
--- a/.github/workflows/nodejs.yml
+++ b/.github/workflows/nodejs.yml
@@ -37,7 +37,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- node-version: [18.x, 20.x, 22.x]
+ node-version: [20.x, 22.x, 24.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
diff --git a/src/router/__tests__/guards.spec.ts
b/src/router/__tests__/guards.spec.ts
index e3d073a8..e7d68d52 100644
--- a/src/router/__tests__/guards.spec.ts
+++ b/src/router/__tests__/guards.spec.ts
@@ -124,16 +124,6 @@ describe("Router Guards", () => {
expect(mockNext).toHaveBeenCalledWith();
});
- it("should redirect to NotFound for routes with invalid parameters", () =>
{
- const validationGuard = createValidationGuard();
- const to = { path: "/invalid", params: { id: "", name: null } };
- const from = { path: "/some-path" };
-
- validationGuard(to, from, mockNext);
-
- expect(mockNext).toHaveBeenCalledWith({ name: "NotFound" });
- });
-
it("should redirect to NotFound for routes with undefined parameters", ()
=> {
const validationGuard = createValidationGuard();
const to = { path: "/invalid", params: { id: undefined } };
@@ -144,14 +134,14 @@ describe("Router Guards", () => {
expect(mockNext).toHaveBeenCalledWith({ name: "NotFound" });
});
- it("should handle mixed valid and invalid parameters", () => {
+ it("should allow empty or null parameters (only undefined is invalid)", ()
=> {
const validationGuard = createValidationGuard();
- const to = { path: "/mixed", params: { id: "123", name: "" } };
+ const to = { path: "/mixed", params: { id: "", name: null } };
const from = { path: "/some-path" };
validationGuard(to, from, mockNext);
- expect(mockNext).toHaveBeenCalledWith({ name: "NotFound" });
+ expect(mockNext).toHaveBeenCalledWith();
});
});
diff --git a/src/router/guards.ts b/src/router/guards.ts
index 34476eb2..072723af 100644
--- a/src/router/guards.ts
+++ b/src/router/guards.ts
@@ -55,9 +55,7 @@ export function createValidationGuard() {
// Validate route parameters if needed
if (to.params && Object.keys(to.params).length > 0) {
// Add custom validation logic here
- const hasValidParams = Object.values(to.params).every(
- (param) => param !== undefined && param !== null && param !== "",
- );
+ const hasValidParams = Object.values(to.params).every((param) => param
!== undefined);
if (!hasValidParams) {
next({ name: "NotFound" });
diff --git a/src/views/components/Pagination.vue
b/src/views/components/Pagination.vue
index 8f771daa..213bc675 100644
--- a/src/views/components/Pagination.vue
+++ b/src/views/components/Pagination.vue
@@ -73,7 +73,9 @@ limitations under the License. -->
const currentPageModel = computed({
get: () => props.currentPage,
- set: (val: number) => emits("update:currentPage", val),
+ set: (val: number) => {
+ void val;
+ },
});
const paginationStyle = computed(() => {