mapbox: URL containing query string causes infinite loop (#5554)

* correct all EXPECT_EQ(actual, expected) to EXPECT_EQ(expected, actual)

* fix getMapboxURLPathname() of URL with querystring

* add test for normalizeSourceURL of non-mapbox protocal

* Update mapbox.cpp
This commit is contained in:
jingsam
2016-07-04 15:26:28 +08:00
committed by Minh Nguyễn
parent 8446a9bef2
commit e82ecc60ac
2 changed files with 54 additions and 22 deletions

View File

@@ -20,13 +20,14 @@ bool isMapboxURL(const std::string& url) {
std::vector<std::string> getMapboxURLPathname(const std::string& url) {
std::vector<std::string> pathname;
std::size_t startIndex = protocol.length();
while (startIndex < url.length()) {
std::size_t end = url.find_first_of("?#");
if (end == std::string::npos) {
end = url.length();
}
while (startIndex < end) {
std::size_t endIndex = url.find("/", startIndex);
if (endIndex == std::string::npos) {
endIndex = url.find_first_of("?#");
}
if (endIndex == std::string::npos) {
endIndex = url.length();
endIndex = end;
}
pathname.push_back(url.substr(startIndex, endIndex - startIndex));
startIndex = endIndex + 1;