restify / restify/node-restify
Improving jsonContentType Regex
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.7k
- Forks
- 975
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 5
Description
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/plugins/utils/regex.js at the jsonContentType expression linked in the issue. Check the proposed pattern against the supplied mixed-case Content-Type example and existing validation behavior; done means valid application types ending in +json are accepted without accepting trailing content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100