const REGEXP = /(\w+)=("[^"]*")/g;

module.exports = (wwwAuthenticate) => {
  const params = {};
  try {
    while (REGEXP.exec(wwwAuthenticate) !== null) {
      if (RegExp.$1 && RegExp.$2) {
        params[RegExp.$1] = RegExp.$2.slice(1, -1);
      }
    }
  } catch (err) {}

  return params;
};
