Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non empty scheme #2

Closed
karunvarma opened this issue Feb 23, 2021 · 2 comments
Closed

Non empty scheme #2

karunvarma opened this issue Feb 23, 2021 · 2 comments

Comments

@karunvarma
Copy link

TEST(UriTests, ParseFromStringHostBarelyLegal) {
struct TestVector {
std::string uriString;
std::string host;
};
const std::vector< TestVector > testVectors{
{"//%41/", "a"},
{"///", ""},
{"//!/", "!"},
{"//'/", "'"},
{"//(/", "("},
{"//;/", ";"},
{"//1.2.3.4/", "1.2.3.4"},
{"//[v7.:]/", "v7.:"},
{"//[v7.aB]/", "v7.aB"},
};
size_t index = 0;
for (const auto& testVector : testVectors) {
UriParser::Uri uri;
ASSERT_TRUE(uri.ParseFromString(testVector.uriString)) << index;
std::cout<<index<<std::endl;
ASSERT_EQ(testVector.host, uri.GetHost());
++index;
}
}

I have a concern regarding this test, URI must have non empty scheme ,but ur code is causing this string to parse successfully.

@karunvarma
Copy link
Author

@rhymu8354 can you look into this , is it a valid test case?

@rhymu8354
Copy link
Owner

rhymu8354 commented Mar 8, 2021

My library technically supports the wider syntax URI-reference which is either a URI or relative-ref per RFC 3986 section 4.1. Although scheme is required for URI, it is not for relative-ref. All the test vectors in ParseFromStringHostBarelyLegal are valid relative-ref examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants