Closed GeorgeGoodall-GovUk closed 3 weeks ago
The changes in this pull request involve modifications to the SubmitUrlController
class in src/controllers/submitUrlController.js
and the addition of new unit tests in test/unit/submitUrlController.test.js
. A new constant for HTTP status 405 is introduced, and the localUrlValidation
method is enhanced to improve error handling for HEAD requests, including logging warnings and returning null
for specific failure scenarios. Corresponding unit tests are added to ensure these new behaviours are correctly validated.
Files | Change Summary |
---|---|
src/controllers/submitUrlController.js |
Added constant HTTP_STATUS_METHOD_NOT_ALLOWED for HTTP 405; updated localUrlValidation method for improved error handling with HEAD requests. |
test/unit/submitUrlController.test.js |
Added new test cases for localUrlValidation to cover HEAD request failures and HTTP 405 responses. |
Objective | Addressed | Explanation |
---|---|---|
Check not accepting endpoints (#[608]) | ✅ | |
bug
In the burrows deep, where the code does leap,
A controller now handles with care, not a peep.
HEAD requests may falter, yet warnings will show,
With tests that ensure our logic will flow.
Hop, skip, and jump, through the lines we weave,
A patch for the bugs, oh, how we believe! 🐰✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Status | Category | Percentage | Covered / Total |
---|---|---|---|
🔵 | Lines | 63.04% | 3729 / 5915 |
🔵 | Statements | 63.04% | 3729 / 5915 |
🔵 | Functions | 64.65% | 161 / 249 |
🔵 | Branches | 81.09% | 446 / 550 |
File | Stmts | Branches | Functions | Lines | Uncovered Lines |
---|---|---|---|---|---|
Changed Files | |||||
src/controllers/submitUrlController.js | 91.39% | 78.57% | 100% | 91.39% | 39-41, 121-124, 147-149, 163-165, 180-182 |
What type of PR is this? (check all applicable)
Description
after a url is submitted in check, During local validation when we get the HEAD object of the url. if the server that hosts the submitted URL doesn't allow head requests, or if the head request fails. don't attempt to perform validations on the head object
Related Tickets & Documents
QA Instructions, Screenshots, Recordings
You can test with this known endpoint, where a head request returns status 405 (method not allowed). but the file itself is valid and should return some check results
Added/updated tests?
Summary by CodeRabbit
New Features
Bug Fixes
Tests