mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2026-04-19 19:19:43 +00:00
Fix validation guard for router (#520)
This commit is contained in:
2
.github/workflows/nodejs.yml
vendored
2
.github/workflows/nodejs.yml
vendored
@@ -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 }}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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" });
|
||||
|
||||
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user