Skip to content

Improving jsonContentType Regex  #1700

@EatonZ

Description

@EatonZ
  • Used appropriate template for the issue type
  • Searched both open and closed issues for duplicates of this issue
  • Title adequately and concisely reflects the feature or the bug

I was getting a PR ready for this, but it said to discuss via Issues first, so here I am. I'm pretty sure this is a good fix, but let me know if I am wrong.

Original:
jsonContentType: new RegExp('^application/[a-zA-Z.]+\\+json') (Link)
My proposed change:
jsonContentType: new RegExp('^application/[a-z0-9.]+\\+json$', 'i')

The original expression was incorrect because it was not checking 0-9, so a valid Content-Type like this would not validate: application/vnd.Microsoft.IIS.Administration.Files.2.2.0+json

Also added the ending $ for completion, and replaced A-Z with the i flag to account for mixed case letters, and also the possibility of mixed case throughout the entire Content-Type.

Are you willing and able to fix this?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions