File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -73,9 +73,7 @@ const types: Record<string, string> = {
73
73
} ;
74
74
75
75
function generateTypes ( content : string ) : string [ ] | undefined {
76
- const pageType = content . match ( / p a g e - t y p e : \s * [ " ' ] ? ( [ ^ " ' \n ] + ) [ " ' ] ? / ) ;
77
- if ( ! pageType ) throw new Error ( "pageType not found" ) ;
78
-
76
+ const pageType = content . match ( / p a g e - t y p e : \s * [ " ' ] ? ( [ ^ " ' \n ] + ) [ " ' ] ? / ) ! ;
79
77
const type = pageType [ 1 ] . split ( "-" ) . pop ( ) ! ;
80
78
const plural = types [ type ] ;
81
79
if ( ! plural ) return ;
@@ -84,9 +82,7 @@ function generateTypes(content: string): string[] | undefined {
84
82
}
85
83
86
84
function generateSlug ( content : string ) : string [ ] {
87
- const match = content . match ( / s l u g : \s * [ " ' ] ? ( [ ^ " ' \n ] + ) [ " ' ] ? / ) ;
88
- if ( ! match ) throw new Error ( "Slug not found" ) ;
89
-
85
+ const match = content . match ( / s l u g : \s * [ " ' ] ? ( [ ^ " ' \n ] + ) [ " ' ] ? / ) ! ;
90
86
const url = match [ 1 ] . split ( ":" ) . pop ( ) ! ;
91
87
const parts = url . split ( "/" ) . slice ( 2 ) ; // skip `/en-US/web/api/...`
92
88
return parts ; // Keep only top-level and method
You can’t perform that action at this time.
0 commit comments