import EscapeStringRegex from 'escape-string-regexp'

export const RouteHasPath = function(route, path) {
  let regEx = new RegExp(EscapeStringRegex(path))
  if (typeof route === 'string') {
    // route is a path
    return regEx.test(route)
  } else {
    return route.matched.some(route => {
      return regEx.test(route.path)
    })
  }
}

export const CurrentRouteHasPath = function(path) {
  let Store = require('../store').default

  return RouteHasPath(Store.state.route.path, path)
}
