javascript regex for extracting filename from Content-Disposition header

后端 未结 6 1540
忘掉有多难
忘掉有多难 2021-01-11 11:58

Content-disposition header contains filename which can be easily extracted, but sometimes it contains double quotes, sometimes no quotes and there are probably some other va

6条回答
  •  别那么骄傲
    2021-01-11 12:14

    /filename[^;=\n]*=(?:(\\?['"])(.*?)\1|(?:[^\s]+'.*?')?([^;\n]*))/i
    

    https://regex101.com/r/hJ7tS6/51

    Edit: You can also use this parser: https://github.com/Rob--W/open-in-browser/blob/master/extension/content-disposition.js

提交回复
热议问题