1
0
Fork 0

urlreducer: new function to be used in responses' treat_line

This commit is contained in:
nemunaire 2019-02-01 17:45:30 +01:00
parent 9417e2ba93
commit 20c19a72bc
1 changed files with 6 additions and 0 deletions

View File

@ -60,6 +60,12 @@ def load(context):
# MODULE CORE #########################################################
def reduce_inline(txt, provider=None):
for url in re.findall("([a-zA-Z0-9+.-]+:(?://)?(?:[^ :/]+:[0-9]+)?[^ :]+)", txt):
txt = txt.replace(url, reduce(url, provider))
return txt
def reduce(url, provider=None):
"""Ask the url shortner website to reduce given URL