Skip to content

Commit

Permalink
Merge pull request NixOS#6380 from thufschmitt/fix-double-slahsh-in-uri
Browse files Browse the repository at this point in the history
Allow empty path segments in urls
  • Loading branch information
edolstra authored Apr 11, 2022
2 parents 2311868 + f3d3587 commit 092f6d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/libutil/tests/url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ namespace nix {
}

TEST(parseURL, parseFileURLWithQueryAndFragment) {
auto s = "file:///none/of/your/business";
auto s = "file:///none/of//your/business";
auto parsed = parseURL(s);

ParsedURL expected {
.url = "",
.base = "",
.scheme = "file",
.authority = "",
.path = "/none/of/your/business",
.path = "/none/of//your/business",
.query = (StringMap) { },
.fragment = "",
};
Expand Down
2 changes: 1 addition & 1 deletion src/libutil/url-parts.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const static std::string userRegex = "(?:(?:" + unreservedRegex + "|" + pctEncod
const static std::string authorityRegex = "(?:" + userRegex + "@)?" + hostRegex + "(?::[0-9]+)?";
const static std::string pcharRegex = "(?:" + unreservedRegex + "|" + pctEncoded + "|" + subdelimsRegex + "|[:@])";
const static std::string queryRegex = "(?:" + pcharRegex + "|[/? \"])*";
const static std::string segmentRegex = "(?:" + pcharRegex + "+)";
const static std::string segmentRegex = "(?:" + pcharRegex + "*)";
const static std::string absPathRegex = "(?:(?:/" + segmentRegex + ")*/?)";
const static std::string pathRegex = "(?:" + segmentRegex + "(?:/" + segmentRegex + ")*/?)";

Expand Down

0 comments on commit 092f6d2

Please sign in to comment.