Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
ce9667c4
Commit
ce9667c4
authored
Dec 09, 2018
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'nghttpx-fix-trailing-slash-handling'
parents
302abf1b
f3f40840
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
src/shrpx_router.cc
src/shrpx_router.cc
+14
-0
src/shrpx_router_test.cc
src/shrpx_router_test.cc
+10
-0
No files found.
src/shrpx_router.cc
View file @
ce9667c4
...
@@ -220,9 +220,16 @@ const RNode *match_partial(bool *pattern_is_wildcard, const RNode *node,
...
@@ -220,9 +220,16 @@ const RNode *match_partial(bool *pattern_is_wildcard, const RNode *node,
return
node
;
return
node
;
}
}
// The last '/' handling, see below.
node
=
find_next_node
(
node
,
'/'
);
if
(
node
!=
nullptr
&&
node
->
index
!=
-
1
&&
node
->
len
==
1
)
{
return
node
;
}
return
nullptr
;
return
nullptr
;
}
}
// The last '/' handling, see below.
if
(
node
->
index
!=
-
1
&&
offset
+
n
+
1
==
node
->
len
&&
if
(
node
->
index
!=
-
1
&&
offset
+
n
+
1
==
node
->
len
&&
node
->
s
[
node
->
len
-
1
]
==
'/'
)
{
node
->
s
[
node
->
len
-
1
]
==
'/'
)
{
return
node
;
return
node
;
...
@@ -265,6 +272,13 @@ const RNode *match_partial(bool *pattern_is_wildcard, const RNode *node,
...
@@ -265,6 +272,13 @@ const RNode *match_partial(bool *pattern_is_wildcard, const RNode *node,
return
node
;
return
node
;
}
}
// The last '/' handling, see below.
node
=
find_next_node
(
node
,
'/'
);
if
(
node
!=
nullptr
&&
node
->
index
!=
-
1
&&
node
->
len
==
1
)
{
*
pattern_is_wildcard
=
false
;
return
node
;
}
return
found_node
;
return
found_node
;
}
}
...
...
src/shrpx_router_test.cc
View file @
ce9667c4
...
@@ -45,6 +45,9 @@ void test_shrpx_router_match(void) {
...
@@ -45,6 +45,9 @@ void test_shrpx_router_match(void) {
{
StringRef
::
from_lit
(
"www.nghttp2.org/alpha/"
),
4
},
{
StringRef
::
from_lit
(
"www.nghttp2.org/alpha/"
),
4
},
{
StringRef
::
from_lit
(
"/alpha"
),
5
},
{
StringRef
::
from_lit
(
"/alpha"
),
5
},
{
StringRef
::
from_lit
(
"example.com/alpha/"
),
6
},
{
StringRef
::
from_lit
(
"example.com/alpha/"
),
6
},
{
StringRef
::
from_lit
(
"nghttp2.org/alpha/bravo2/"
),
7
},
{
StringRef
::
from_lit
(
"www2.nghttp2.org/alpha/"
),
8
},
{
StringRef
::
from_lit
(
"www2.nghttp2.org/alpha2/"
),
9
},
};
};
Router
router
;
Router
router
;
...
@@ -84,6 +87,13 @@ void test_shrpx_router_match(void) {
...
@@ -84,6 +87,13 @@ void test_shrpx_router_match(void) {
idx
=
router
.
match
(
StringRef
::
from_lit
(
"nghttp2.org"
),
idx
=
router
.
match
(
StringRef
::
from_lit
(
"nghttp2.org"
),
StringRef
::
from_lit
(
"/alpha/bravo"
));
StringRef
::
from_lit
(
"/alpha/bravo"
));
CU_ASSERT
(
3
==
idx
);
idx
=
router
.
match
(
StringRef
::
from_lit
(
"www2.nghttp2.org"
),
StringRef
::
from_lit
(
"/alpha"
));
CU_ASSERT
(
8
==
idx
);
idx
=
router
.
match
(
StringRef
{},
StringRef
::
from_lit
(
"/alpha"
));
idx
=
router
.
match
(
StringRef
{},
StringRef
::
from_lit
(
"/alpha"
));
CU_ASSERT
(
5
==
idx
);
CU_ASSERT
(
5
==
idx
);
...
...
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