[fix] Fix prefix writing in project redirects

parent be19fe65
......@@ -39,9 +39,7 @@ class HtaccessReader:
f = open(abs_path, 'r', encoding='UTF-8')
for line in f:
print('line is', line)
if len(line) > 2 and not line.startswith('#'):
if len(line) > 2 and not line.startswith('#') and '#' not in line:
res.append('\n')
res.append('# {}'.format(line)) # for tests
res.append(self.line_parser.parse_line(line))
......
import os
NAME = "nginx-redirector"
VERSION = "1.0.0"
VERSION = "0.1.2"
AUTHOR = "Nikita Yefremov, David Dobryakov"
EMAIL = "kantegory@etersoft.ru"
PYTHON_VERSION = "3.8.1"
......
......@@ -50,6 +50,7 @@ class MapGenerator:
def generate_map(self, redirects, project_name):
data = self.start_line % project_name
for arg1, arg2 in redirects:
# print('redirect is', arg1, arg2)
data += "\n\t%s\t%s;" % (arg1, arg2)
data += self.endline
return data
......
......@@ -41,23 +41,20 @@ class MapLineParser:
print(line[0])
if line[0].startswith("~"):
line[0] = "~" + prefix + line[0][1:]
line[0] = "~" + line[0][1:]
if line[0].startswith("//"): # if new URI relative to the root
line[0] = line[0][1:] # cutting out extra '/' at the beginning
line[1] = prefix + line[1]
elif line[1].startswith("//"):
line[1] = line[1][1:]
line[0] = prefix + line[0] if not line[0].startswith("~") else line[0]
line[0] = line[0]
elif self.url_absolute.fullmatch(line[1]):
line[0] = prefix + line[0]
options = ['301']
return_code = 1
else: # default url
line[0] = prefix + line[0] if not line[0].startswith("~") else line[0]
line[1] = prefix + line[1]
line[0] = line[0] if not line[0].startswith("~") else line[0]
return return_code, line[0], line[1], options
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment