title: Node https get file from url and unzip
body: <p>I am using node https/http module to download file. The code looks like this:</p>
  
  <pre><code>https.get(url)
  .on('response', (response) =&gt; {
      response.pipe(fs.createWriteStream(dataDir + filename))
  }
  </code></pre>
  
  <p>In the next step I use <a href="https://github.com/EvanOxfeld/node-unzip" rel="nofollow noreferrer">unzip</a> module to unzip the file.</p>
  
  <pre><code>fs.createReadStream(dataDir + filename)
  .pipe(unzip.Extract({path: dataDir}))
  .on('close', () =&gt; { something }
  .on('error', () =&gt; { catch error}
  </code></pre>
  
  <p>For most cases, Everything works well. However, sometimes unzip module returns this error:</p>
  
  <pre><code>Error: invalid signature: 0x6d74683c
  </code></pre>
  
  <p>The only issue I can notice is the file name. I grab filename from url. It is the last parameter of a url.  However, in some cases, the exact filename is different from the one shown in url. For instance:</p>
  
  <pre><code>https://github.com/request/request/archive/master.zip
  </code></pre>
  
  <p>The name shown in url is <code>master.zip</code> but when I download it the name is  <code>request-master.zip</code>.</p>
  
  <p>Is this the actual problem? If so, how can I solve it? </p>