How do I regex a Content-Disposition header value in postman?

Viewed 417

I am adding some tests into my postman API request and I was wondering how I can give a regex into the Content-Disposition header value, I have something like this but date is dynamic and just wanted to regex or do some other approach, any ideas?

pm.test("My test file name is downloaded successfully", function () {
    pm.response.to.have.header("Content-Disposition", "attachment; filename=Test Project_information_10_15_2021.xlsx");
1 Answers

You can do this:

pm.test("My test file name is downloaded successfully", () => { 
    const content = pm.response.headers.get("Content-Disposition");
    pm.expect(content).to.match(/^attachment.+xlsx$/);
});
Related