Skip to content

Commit 882ffe9

Browse files
committed
fix(pagination): always return undfined when there's no link
1 parent fae4d5f commit 882ffe9

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/pagination.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ import type { Link } from "./standard-schemas.ts";
33
const pageParamRegexp = /^page\[([a-zA-Z0-9]+)]$/;
44
export type PageParams = Record<string, string>;
55

6-
export const parsePageParamsFromLink = (
7-
link: Link | undefined | null,
8-
): PageParams | undefined | null => {
6+
export const parsePageParamsFromLink = (link: Link | undefined | null): PageParams | undefined => {
97
if (link === undefined || link === null) {
10-
return link;
8+
return undefined;
119
}
1210

1311
const url = new URL(typeof link === "string" ? link : link.href, "http://localhost");

test/pagination.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { describe, expect, it } from "vitest";
22
import { injectPageParams, parsePageParamsFromLink } from "../src/index.js";
33

44
describe("parsePageParams", () => {
5-
it("should return falsy link", () => {
5+
it("should return undefined on falsy link", () => {
66
expect(parsePageParamsFromLink(undefined)).toBeUndefined();
7-
expect(parsePageParamsFromLink(null)).toBeNull();
7+
expect(parsePageParamsFromLink(null)).toBeUndefined();
88
});
99

1010
it("should throw when not finding page params", () => {

0 commit comments

Comments
 (0)