Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nginx-redirector
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
eterfund
nginx-redirector
Commits
9c8f9deb
Commit
9c8f9deb
authored
Nov 03, 2021
by
Давид Добряков
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix] Fix prefix writing in project redirects
parent
be19fe65
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
10 deletions
+6
-10
htaccess_parser.py
redirector/htaccess_parser.py
+1
-3
const.py
redirector/utils/const.py
+1
-1
generators.py
redirector/utils/generators.py
+1
-0
parser.py
redirector/utils/parser.py
+3
-6
No files found.
redirector/htaccess_parser.py
View file @
9c8f9deb
...
@@ -39,9 +39,7 @@ class HtaccessReader:
...
@@ -39,9 +39,7 @@ class HtaccessReader:
f
=
open
(
abs_path
,
'r'
,
encoding
=
'UTF-8'
)
f
=
open
(
abs_path
,
'r'
,
encoding
=
'UTF-8'
)
for
line
in
f
:
for
line
in
f
:
print
(
'line is'
,
line
)
if
len
(
line
)
>
2
and
not
line
.
startswith
(
'#'
)
and
'#'
not
in
line
:
if
len
(
line
)
>
2
and
not
line
.
startswith
(
'#'
):
res
.
append
(
'
\n
'
)
res
.
append
(
'
\n
'
)
res
.
append
(
'# {}'
.
format
(
line
))
# for tests
res
.
append
(
'# {}'
.
format
(
line
))
# for tests
res
.
append
(
self
.
line_parser
.
parse_line
(
line
))
res
.
append
(
self
.
line_parser
.
parse_line
(
line
))
...
...
redirector/utils/const.py
View file @
9c8f9deb
import
os
import
os
NAME
=
"nginx-redirector"
NAME
=
"nginx-redirector"
VERSION
=
"
1.0.0
"
VERSION
=
"
0.1.2
"
AUTHOR
=
"Nikita Yefremov, David Dobryakov"
AUTHOR
=
"Nikita Yefremov, David Dobryakov"
EMAIL
=
"kantegory@etersoft.ru"
EMAIL
=
"kantegory@etersoft.ru"
PYTHON_VERSION
=
"3.8.1"
PYTHON_VERSION
=
"3.8.1"
...
...
redirector/utils/generators.py
View file @
9c8f9deb
...
@@ -50,6 +50,7 @@ class MapGenerator:
...
@@ -50,6 +50,7 @@ class MapGenerator:
def
generate_map
(
self
,
redirects
,
project_name
):
def
generate_map
(
self
,
redirects
,
project_name
):
data
=
self
.
start_line
%
project_name
data
=
self
.
start_line
%
project_name
for
arg1
,
arg2
in
redirects
:
for
arg1
,
arg2
in
redirects
:
# print('redirect is', arg1, arg2)
data
+=
"
\n\t
%
s
\t
%
s;"
%
(
arg1
,
arg2
)
data
+=
"
\n\t
%
s
\t
%
s;"
%
(
arg1
,
arg2
)
data
+=
self
.
endline
data
+=
self
.
endline
return
data
return
data
...
...
redirector/utils/parser.py
View file @
9c8f9deb
...
@@ -41,23 +41,20 @@ class MapLineParser:
...
@@ -41,23 +41,20 @@ class MapLineParser:
print
(
line
[
0
])
print
(
line
[
0
])
if
line
[
0
]
.
startswith
(
"~"
):
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
if
line
[
0
]
.
startswith
(
"//"
):
# if new URI relative to the root
line
[
0
]
=
line
[
0
][
1
:]
# cutting out extra '/' at the beginning
line
[
0
]
=
line
[
0
][
1
:]
# cutting out extra '/' at the beginning
line
[
1
]
=
prefix
+
line
[
1
]
elif
line
[
1
]
.
startswith
(
"//"
):
elif
line
[
1
]
.
startswith
(
"//"
):
line
[
1
]
=
line
[
1
][
1
:]
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
]):
elif
self
.
url_absolute
.
fullmatch
(
line
[
1
]):
line
[
0
]
=
prefix
+
line
[
0
]
options
=
[
'301'
]
options
=
[
'301'
]
return_code
=
1
return_code
=
1
else
:
# default url
else
:
# default url
line
[
0
]
=
prefix
+
line
[
0
]
if
not
line
[
0
]
.
startswith
(
"~"
)
else
line
[
0
]
line
[
0
]
=
line
[
0
]
if
not
line
[
0
]
.
startswith
(
"~"
)
else
line
[
0
]
line
[
1
]
=
prefix
+
line
[
1
]
return
return_code
,
line
[
0
],
line
[
1
],
options
return
return_code
,
line
[
0
],
line
[
1
],
options
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment