replace first the url before the terms

This commit is contained in:
tdurieux
2017-10-18 14:43:11 +02:00
parent 72386120f6
commit 704de268d1

View File

@@ -53,13 +53,14 @@ class Anonymous_Github:
application.jinja_env.add_extension('jinja2.ext.do')
def removeTerms(content, repository):
for term in repository['terms']:
content = re.compile(term, re.IGNORECASE).sub("XXX", content)
repo = repository['repository']
if repo[-1] == '/':
repo = repo[0:-1]
content = re.compile(repo + "/blob/master", re.IGNORECASE).sub(self.public_url + "/repository/" + repository["id"], content)
content = re.compile(repo, re.IGNORECASE).sub(self.public_url+"/repository/" + repository["id"], content)
content = re.compile(repo + "/blob/master", re.IGNORECASE).sub(
self.public_url + "/repository/" + repository["id"], content)
content = re.compile(repo, re.IGNORECASE).sub(self.public_url + "/repository/" + repository["id"], content)
for term in repository['terms']:
content = re.compile(term, re.IGNORECASE).sub("XXX", content)
return content
@application.template_filter('file_render', )