(
id: string | undefined | null = '',
{ uuid = true }: { uuid?: boolean } = {}
)
| 12 | * Defaults to returning a UUID (with dashes). |
| 13 | */ |
| 14 | export const parsePageId = ( |
| 15 | id: string | undefined | null = '', |
| 16 | { uuid = true }: { uuid?: boolean } = {} |
| 17 | ): string | undefined => { |
| 18 | if (!id) return |
| 19 | |
| 20 | id = id.split('?')[0]! |
| 21 | if (!id) return |
| 22 | |
| 23 | const match = id.match(pageIdRe) |
| 24 | |
| 25 | if (match) { |
| 26 | return uuid ? idToUuid(match[1]) : match[1] |
| 27 | } |
| 28 | |
| 29 | const match2 = id.match(pageId2Re) |
| 30 | if (match2) { |
| 31 | return uuid ? match2[1] : match2[1]!.replaceAll('-', '') |
| 32 | } |
| 33 | |
| 34 | return |
| 35 | } |
no test coverage detected