let filename = "Test.xlsx"; var disposition = response.headers["content-disposition"] var filenameRegex = /filename[^;= ]*=((['"]).*?2|[^; ]*)/; var matches = filenameRegex.exec(disposition); if (matches != null && matches[1]) { filename = matches[1].replace(/['"]/g, ''); }