title: How to split Json Web Token as Header-Payload-Signature in Node.JS
body: <p>I have node.js application. I use Json Web Token for autherization. JWT has three parts named header, payload and signature. There is a dot between these parts as shown in the below.</p>
  
  <pre><code>token = header.payload.signature  ||  token= xxxxx.yyyyyy.zzzzz
  
  token = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
  </code></pre>
  
  <p>I need to get the payload value (the middle part) from the created token of header. I need to split the token as 3 parts (Header-Payload-Signature).</p>
  
  <p>I use this method:</p>
  
  <pre><code>const token= req.headers.authorization.split("")[1];
  header,payload,signature = token.split('.')
  </code></pre>
  
  <p>But this doesn't work. Is there any other splitting method or suggestion for me ?</p>
  
  <p><strong>EDIT: It can be considered as I have a string (which is basically a file name following a naming convention) abc.def.ghi</strong></p>
  
  <p><strong>I would like to extract the substring before the first . (ie a dot)</strong></p>
  
  <p><strong>In javascript, How can I do that ?</strong></p>