@@ -306,15 +306,15 @@ module.exports = {
306306 } ,
307307 code : ( node ) => {
308308 const apiMethods = [ 'GET' , 'POST' , 'PUT' , 'DELETE' , 'PATCH' , 'HEAD' , 'OPTIONS' ] ;
309- const splitValue = node . value . trim ( ) . split ( '\n' ) ;
309+ const splitValueLines = node . value . trim ( ) . split ( '\n' ) ;
310310
311- splitValue . forEach ( ( item , i , valuesArray ) => {
312- if ( ! apiMethods . some ( ( method ) => item . startsWith ( method ) ) ) {
311+ splitValueLines . forEach ( ( item , i , valuesArray ) => {
312+ if ( apiMethods . some ( ( method ) => item . trim ( ) === method ) ) {
313313 // try to parse as URL, if successful, prefix with absolute URL
314314 try {
315315 const parsedUrl = parse ( valuesArray [ i + 1 ] ) ;
316316 if ( isInternal ( parsedUrl ) && parsedUrl . pathname ) {
317- valuesArray [ i + 1 ] = `${ config . absoluteUrl } ${ parsedUrl . pathname } ` ;
317+ splitValueLines [ i + 1 ] = `${ config . absoluteUrl } ${ parsedUrl . pathname } ` ;
318318 }
319319 } catch {
320320 // do nothing, leave the line as is
@@ -323,9 +323,9 @@ module.exports = {
323323 } ) ;
324324
325325 if ( apiMethods . some ( ( method ) => node . value . trim ( ) . startsWith ( method ) ) ) {
326- node . lang = node . lang . toLowerCase ( ) ;
326+ node . lang = node . lang ? .toLowerCase ( ) ;
327327 }
328- return `\n\`\`\`${ node . lang || '' } \n${ node . value } \n\`\`\`\n` ;
328+ return `\n\`\`\`${ node . lang || '' } \n${ splitValueLines . join ( '\n' ) } \n\`\`\`\n` ;
329329 } ,
330330 } ,
331331 } ,
0 commit comments