Skip to content

Commit d8be554

Browse files
committed
throw error if slug doesnt match regex
1 parent e7f35e1 commit d8be554

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/gatsby/onPostBuild.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ const parsePathSlug = (slug: string) => {
7272
const pathMatch = slug.match(
7373
/^\/(?<platform>[^/]+)\/performance-onboarding\/(?<sub_platform>[^/]+)\/(?<step>[^/]+)\/$/
7474
);
75+
76+
if(!pathMatch) {
77+
throw new Error(`Unable to parse performance onboarding from slug: ${slug}`);
78+
}
79+
7580
const { platform, sub_platform } = pathMatch.groups;
7681
const step = String(pathMatch.groups.step).replace(/\./g, "-");
7782
const sub = platform === sub_platform ? `performance-onboarding-${step}` : `performance-onboarding-${sub_platform}-${step}`;

0 commit comments

Comments
 (0)