regex for Xifin Challenge

by Gerald Gillespie

JavaScript

//the regex preserves the "==" on the nonce while splitting correctly
 const obj = `Digest realm="xifinRealm", qop="auth", nonce="MTYzNTEzMjM1NDI0MjpkNTEwZDlmODlkZDdlYWZmZGRlMjgxMTRmZDEwNjUzOA=="`.split(', ').reduce( (result,item, index)=>{
      //  let [key,value] = item.split('="'); 
        let [garbage,key,value] = item.match(/^([^=]*)="([^=].*)"$/)
        result[key] = value; 
        
        return result;
        
      }, {} );
      
      
      
      console.log( obj)