aws-cdk-examples icon indicating copy to clipboard operation
aws-cdk-examples copied to clipboard

String replacement used in image-content-search Python example

Open samtwil opened this issue 3 years ago • 1 comments
trafficstars

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

samtwil avatar May 17 '22 12:05 samtwil

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.

NGL321 avatar Jun 03 '22 18:06 NGL321

⚠️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.

github-actions[bot] avatar Dec 27 '24 22:12 github-actions[bot]

⚠️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.

github-actions[bot] avatar Dec 27 '24 22:12 github-actions[bot]