Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
5e1a06fd
Commit
5e1a06fd
authored
Nov 26, 2018
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't add an empty path component on trailing slash.
parent
a358282e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
url-test.c++
c++/src/kj/compat/url-test.c++
+12
-0
url.c++
c++/src/kj/compat/url.c++
+2
-1
No files found.
c++/src/kj/compat/url-test.c++
View file @
5e1a06fd
...
...
@@ -294,6 +294,18 @@ KJ_TEST("parse / stringify URL") {
// "." and ".." are still processed, though.
parseAndCheck
(
"https://capnproto.org/foo//../bar/."
,
"https://capnproto.org/foo/bar/"
,
ALLOW_EMPTY
);
{
auto
url
=
parseAndCheck
(
"https://foo/"
,
nullptr
,
ALLOW_EMPTY
);
KJ_EXPECT
(
url
.
path
.
size
()
==
0
);
KJ_EXPECT
(
url
.
hasTrailingSlash
);
}
{
auto
url
=
parseAndCheck
(
"https://foo/bar/"
,
nullptr
,
ALLOW_EMPTY
);
KJ_EXPECT
(
url
.
path
.
size
()
==
1
);
KJ_EXPECT
(
url
.
hasTrailingSlash
);
}
}
KJ_TEST
(
"URL percent encoding"
)
{
...
...
c++/src/kj/compat/url.c++
View file @
5e1a06fd
...
...
@@ -233,7 +233,8 @@ Maybe<Url> Url::tryParse(StringPtr text, Context context, Options options) {
result
.
path
.
removeLast
();
}
result
.
hasTrailingSlash
=
true
;
}
else
if
((
part
.
size
()
==
0
&&
!
options
.
allowEmpty
)
||
(
part
.
size
()
==
1
&&
part
[
0
]
==
'.'
))
{
}
else
if
((
part
.
size
()
==
0
&&
(
!
options
.
allowEmpty
||
text
.
size
()
==
0
))
||
(
part
.
size
()
==
1
&&
part
[
0
]
==
'.'
))
{
// Collapse consecutive slashes and "/./".
result
.
hasTrailingSlash
=
true
;
}
else
{
...
...
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