mirror of http://git.simp.i2p/simp/i2pnews.git
normalize any links that appear to be going to localhost
parent
7a543d615b
commit
583568713b
3
app.py
3
app.py
|
@ -683,6 +683,9 @@ class Irc_bot:
|
|||
msg_url = (self.feed_dict[url])['link'][i]
|
||||
col = self.color_dict[feed_url[url]['category']]
|
||||
shorten = get_short_url(url)
|
||||
if get_host(msg_url).casefold() == '127.0.0.1':
|
||||
url_q = msg_url.split(shorten)[1]
|
||||
msg_url = f'http://{shorten}{url_q}'
|
||||
msg_s = (f"{col}[{shorten}]{Color.normal} {msg_title} - {msg_url}")
|
||||
# msg_f = f'''{msg_title} - {msg_description} ::{msg_url}'''
|
||||
msg_f = f'''::{msg_url} @@@{msg_title}'''
|
||||
|
|
11
functions.py
11
functions.py
|
@ -261,6 +261,12 @@ def get_short_url(long_url):
|
|||
x = ''
|
||||
url = f'{short}{x}'
|
||||
return url
|
||||
def get_host(long_url):
|
||||
host_port = long_url
|
||||
p = '(?:http.*://)?(?P<host>[^:/ ]+).?(?P<port>[0-9]*).*'
|
||||
m = re.search(p,long_url)
|
||||
short = m.group('host')
|
||||
return short
|
||||
def format_msg(single_msg_raw, topic):
|
||||
single_msg = single_msg_raw[:-1]
|
||||
l = single_msg.split(' ')
|
||||
|
@ -285,10 +291,13 @@ def format_msg(single_msg_raw, topic):
|
|||
post_url_list = []
|
||||
for i in range(0, len(l)):
|
||||
if '::' == l[i][:2]:
|
||||
if l[i][:6].lower() != '::http':
|
||||
if l[i][:6].casefold() != '::http':
|
||||
post_url = f'http://{nick_raw}{l[i][2:]}'
|
||||
else:
|
||||
post_url = (single_msg.split('::')[1]).split(' @@@')[0]
|
||||
if get_host(post_url).casefold() == '127.0.0.1':
|
||||
url_q = post_url.split(get_short_url(post_url))[1]
|
||||
post_url = f'http://{nick_raw}{url_q}'
|
||||
l[i] = ''
|
||||
read_more = f'''<div contenteditable="false"><a href="{post_url}" target="_blank">Read More</a></div>'''
|
||||
elif '@@@' == l[i][:3]:
|
||||
|
|
Loading…
Reference in New Issue