I am building a python (3.6) function that will work as a microservice that expects the payload to be a url string. I use validators.url to check if the string passed is like a URL before executing the function which includes requests.get call to get the website at the URL.
The problem occurs if the url string passed is itself wrapped in single or double quotes. In that case the function fails.
so:
localohost:1234/api/Function?url=https://www.google.com
works but
localohost:1234/api/Function?url='https://www.google.com'
and
localohost:1234/api/Function?url="https://www.google.com"
both fail to execute both because they are not like URL and because requests.get cannot interpret the string. This is an edge case, but one I'd love to handle properly.
Is there a way to check for a string with "doubled up quotation marks" (as in '"string"'
or "'string'"
) in Python and remove them?
Thanks