-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor body_does_not_contain_lead_image validator
This commit refactors the `body_does_not_contain_lead_image` custom validation method to reduce its coupling to Govspeak. Right now it uses regular expressions to check if the lead image has been embedded into the document body. This relies upon the validator knowing the specific Govspeak syntax that would be used to embed the image (of which there are two different variants). This refactor takes a more 'black box' approach by rendering the Govspeak as HTML, and then inspecting the output to see if it contains the lead image. This way the validator doesn't need to parse the Govspeak syntax directly – making it more robust against future changes to the syntax. I imagine this new approach is slightly less performant. It now renders and inspects the resultant HTML, rather than simply matching a regex against the raw Govspeak. However I expect this will have negligible overall impact on performance, so would be a net benefit given the improvements to code readability and cleanliness.
- Loading branch information
1 parent
05969b5
commit a3d5bb3
Showing
4 changed files
with
26 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters