编辑代码

const res2 = '/app/40340204/renderDetail/taskForm/defg/40340204'
 const templatePathMapping = {
  taskForm: '^/app/:appId/renderDetail/:formId/:bizId$',
  flowTodoForm: '^/app/:appId/renderDetail/:flowId$',
  flowDoneForm: '^/app/:appId/renderDetail/:flowId$',
  flowRegisterForm: '^/app/:appId/renderDetail/:flowId$'
}

function checkRenderDetailPath (path) {
  let templatesStr = Object.keys(templatePathMapping).join('|')
  let reg = new RegExp(
    `/app/[0-9a-zA-Z]*?/renderDetail/(${templatesStr})/[0-9a-zA-Z]*`
  )
  let matchRes = path.match(reg)
  console.log(matchRes)
  if (matchRes) {
    return matchRes[1]
  }
}
console.log(checkRenderDetailPath(res2))