'use strict'

const parseUrl = require('./url')
const parsePath = require('./path')

async function parse(token, options) {
  try {
    options.logger.log('analyze:start', token)

    switch (token.inputType) {
      case 'url':
        await parseUrl(token, options)

        if (token.path && !token.parsed) {
          await parsePath(token, options)
        }
        break

      case 'path':
        await parsePath(token, options)
        break

      default:
        throw new Error(`Unknown token inputType ${token.inputType}`)
    }
  } catch (err) {
    token.type = 'error'
    token.error = err.message
    token.parsed = true
  }

  if (!token.parsed) {
    throw new Error(`Token with location ${token.location} was not analyzed`)
  }

  options.logger.log('analyze:end', token)

  if (token.children) {
    await Promise.all(token.children.map(token => parse(token, options)))
  }
}

module.exports = parse

@@ -181,22 +181,18 @@
     
-switch
+if
  (token.
 inpu
@@ -191,41 +191,15 @@
 ken.
-inputType
+url
 ) %7B%0A
-      case 'url':%0A  
     
@@ -231,21 +231,23 @@
 ptions)%0A
-%0A
     
+%7D%0A%0A
     if (
@@ -260,33 +260,12 @@
 path
- && !token.parsed) %7B%0A    
+) %7B%0A
     
@@ -302,192 +302,8 @@
 ns)%0A
-        %7D%0A        break%0A%0A      case 'path':%0A        await parsePath(token, options)%0A        break%0A%0A      default:%0A        throw new Error(%60Unknown token inputType $%7Btoken.inputType%7D%60)%0A
     

Simplify input type switch