File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,30 @@ pub fn normalize(
109109 ) ;
110110 }
111111
112+ // validate format of 'path'
113+ {
114+ let mut path = front_matter. path . as_str ( ) ;
115+ let mut rq_fmt = "YYYY/MM/DD/slug-of-your-choice" ;
116+ if inside_rust {
117+ rq_fmt = "inside-rust/YYYY/MM/DD/slug-of-your-choice" ;
118+ if !path. starts_with ( "inside-rust/" ) {
119+ bail ! ( "the path of inside-rust posts must start with 'inside-rust/'" ) ;
120+ }
121+ path = path. trim_start_matches ( "inside-rust/" ) ;
122+ }
123+ let components = path. split ( '/' ) . collect :: < Vec < _ > > ( ) ;
124+ if components. len ( ) != 4
125+ || components[ 0 ] . len ( ) != 4
126+ || components[ 0 ] . parse :: < u32 > ( ) . is_err ( )
127+ || components[ 1 ] . len ( ) != 2
128+ || components[ 1 ] . parse :: < u8 > ( ) . is_err ( )
129+ || components[ 2 ] . len ( ) != 2
130+ || components[ 2 ] . parse :: < u8 > ( ) . is_err ( )
131+ {
132+ bail ! ( "invalid 'path' key in front matter, required format: {rq_fmt}" ) ;
133+ }
134+ }
135+
112136 if front_matter. extra . team . is_some ( ) ^ front_matter. extra . team_url . is_some ( ) {
113137 bail ! ( "extra.team and extra.team_url must always come in a pair" ) ;
114138 }
You can’t perform that action at this time.
0 commit comments