aws-cdk-examples
aws-cdk-examples copied to clipboard
String replacement used in image-content-search Python example
Describe the bug
During code review of a separate PR, it was noticed that python/image-content-search/src/landingPage/main.py uses a string replacement. This is Not Great
Expected Behavior
No usage of the string.replace() method is expected
Current Behavior
Around line 14 of python/image-content-search/src/landingPage/main.py, we have the following line:
'body': file_get_contents("index.html").replace('###loginPage###', login_page)
Reproduction Steps
Open python/image-content-search/src/landingPage/main.py` and review the code, no deployment necessary
Possible Solution
One possible alternative is to use the sub function from the re module
import re
foo = 'this is my string'
rs.sub('my', '', foo)
# foo = 'this is string'
Additional Information/Context
No response
CDK CLI Version
Framework Version
No response
Node.js Version
OS
Language
Python
Language Version
No response
Since this is a request for an enhancement (the code isn't broken, just has a poor approach), I have switched the issue to a feature-request. However I have kept a high priority since it seems that this is something that should be tackled sooner than later.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
⚠️COMMENT VISIBILITY WARNING⚠️
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.