node-restify icon indicating copy to clipboard operation
node-restify copied to clipboard

Improving jsonContentType Regex

Open EatonZ opened this issue 5 years ago • 7 comments

  • [x] Used appropriate template for the issue type
  • [x] Searched both open and closed issues for duplicates of this issue
  • [x] 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

EatonZ avatar Sep 01 '18 00:09 EatonZ

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 31 '18 20:10 stale[bot]

Any feedback?

EatonZ avatar Oct 31 '18 20:10 EatonZ

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 30 '18 23:12 stale[bot]

👀

EatonZ avatar Dec 30 '18 23:12 EatonZ

jsonContentType: new RegExp('^application/[a-z0-9.-]+\+json$', 'i') - to use in example application/merge-patch+json

FernandoFranco avatar Jan 20 '20 11:01 FernandoFranco

Heya @EatonZ, this looks good to me :+1: will merge a PR implementing this assuming tests pass!

retrohacker avatar Apr 01 '20 21:04 retrohacker

@retrohacker Any luck?

EatonZ avatar Oct 03 '20 03:10 EatonZ