All files / apps/wp-editor/server/utils itemKey.ts

100% Statements 3/3
100% Branches 2/2
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8    2x 1872x   1872x    
import type { PostType } from "../../shared/types/PostType.ts";
 
export const parseKey = (key: string): { type: PostType; id: number } | null => {
    const match = /^(posts|pages)-(\d+)$/.exec(key);
 
    return match ? { type: match[1] as PostType, id: Number(match[2]) } : null;
};