Skip to content

Commit 581647d

Browse files
fix: parsePageId returns undefined for invalid inputs instead of null
1 parent 64f6711 commit 581647d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/notion-utils/src/parse-page-id.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ const pageId2Re = /\b([\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12})\b/
1212
* Defaults to returning a UUID (with dashes).
1313
*/
1414
export const parsePageId = (
15-
id: string | null = '',
15+
id: string | undefined | null = '',
1616
{ uuid = true }: { uuid?: boolean } = {}
17-
) => {
18-
if (!id) return null
17+
): string | undefined => {
18+
if (!id) return
1919

2020
id = id.split('?')[0]!
21-
if (!id) return null
21+
if (!id) return
2222

2323
const match = id.match(pageIdRe)
2424

@@ -31,5 +31,5 @@ export const parsePageId = (
3131
return uuid ? match2[1] : match2[1]!.replaceAll('-', '')
3232
}
3333

34-
return null
34+
return
3535
}

0 commit comments

Comments
 (0)